KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an application that consists of using ActionBarSherlock in tab mode.I have 5 tabs and the content of each tab is handled using fragments. For tab2 though, I have a fragment the xml file of which holds a ViewPager element which in turn has some fragment pages. When I initially start the application the application, I am able to switch between tabs no problem but when I press on tab2 for the second time I get the error mentioned above. The main activity is as follows: public class MainActivity extends SherlockFragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ActionBar actionBar = getSupportActionBar(); ActionBar.Tab tab1 = actionBar.newTab().setText("Tab1"); ActionBar.Tab tab3 = actionBar.newTab().setText("Tab3"); ActionBar.Tab tab2 = actionBar.newTab().setText("Tab2"); ActionBar.Tab tab4 = actionBar.newTab().setText("Tab4"); ActionBar.Tab tab5 = actionBar.newTab().setText("Tab5"); Fragment fragment1 = new Tab1(); Fragment fragment3 = new Tab3(); Fragment fragment2 = new Tab2(); Fragment fragment5 = new Tab5(); Fragment fragment4 = new Tab4(); tab1.setTabListener(new MyTabListener(fragment1)); tab3.setTabListener(new MyTabListener(fragment3)); tab2.setTabListener(new MyTabListener(fragment2)); tab5.setTabListener(new MyTabListener(fragment5)); tab4.setTabListener(new MyTabListener(fragment4)); actionBar.addTab(tab1); actionBar.addTab(tab2); actionBar.addTab(tab3); actionBar.addTab(tab4); actionBar.addTab(tab5); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } class MyTabListener implements ActionBar.TabListener { Fragment fragment; public MyTabListener(Fragment fragment) {
Tags (comma-separated)
Save Edits
Cancel