I don't seem to understand if it's possible to inflate (include) an activity into another activity. I know i can inflate a layout xml, this works, but i am wondering if i can inflate an activity. For instance , i have class A that extends Activity and another class B that extends ListActivity. Can i include and use in class A, my class B? THis is what i have tried:
Class A:
LayoutInflater inflater = (LayoutInflater) MyActivity.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// inflate list
BActivity list = new BActivity();
Class B:
public class BActivity extends ListActivity {
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
List<Model> models= new ArrayList<Model>();
models.add(new Model("John"));
models.add(new Model("Cage"));
setListAdapter(new MyAdapter(this, models));
ListView list = getListView();
}
}
and in xml (the class A xml): (for where i want to see the list)
<view class="com.test.BActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content" > </view>
All of this throws errors :
Error inflating class BActivity
The activities are declared in the manifest.
Do you know what i am doing wrong? this is not the correct way to inflate another activity? I am using Android 2.2 api 8. Thank you for your time.