Reputation: 15976
I have quite a large hierarchy of classes that are Activities. I just installed the v4 compatibility package. What is the easiest way to get all my Activities in a way that I can use them in a Fragment with a TabHost inside of it?
Line of code:
mTabsAdapter.addTab(mTabHost.newTabSpec("feed").setIndicator("Feed"), FActivity.class, null);
Line 165:
@Override
public Fragment getItem(int position) {
TabInfo info = mTabs.get(position);
return Fragment.instantiate(mContext, info.clss.getName(), info.args);
}
Specifically I want to avoid errors like:
07-19 01:33:24.940: ERROR/AndroidRuntime(17581): java.lang.ClassCastException: com.c.FActivity
07-19 01:33:24.940: ERROR/AndroidRuntime(17581): at android.support.v4.app.Fragment.instantiate(Fragment.java:378)
07-19 01:33:24.940: ERROR/AndroidRuntime(17581): at com.c.Main$TabsAdapter.getItem(Main.java:165)
07-19 01:33:24.940: ERROR/AndroidRuntime(17581): at android.support.v4.app.FragmentPagerAdapter.instantiateItem(FragmentPagerAdapter.java:62)
Upvotes: 3
Views: 6140
Reputation: 40193
Here are a few links that you might find interesting. There is an example of creating a two-activity application, and then implementing fragments into it.
Android User Interface Design: Working With Fragments
Android Compatibility: Working with Fragments
Hope this helps.
Upvotes: 6