2

I'm trying to include one activity inside another.

<include
    android:id = "@+id/includedactivity"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    layout="@layout/maintabactivity" />

I can see all included's activity controls, but onCreate method of maintabactivity is never get called.

4

1 回答 1

2
<include
android:id = "@+id/includedactivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/maintabactivity" /> 

only includes the layout in your current layout file in the view rather then it would not call the oncreate method of any other activity. I think you want to launch another activity to show the new layout.

    Intent intent = new Intent();
    intent.setClass(getApplicationContext(), NewActivity.class);
    startActivity(intent);  
于 2012-06-03T06:59:54.503 回答