lunch different activities?

Put your problem here if it does not fit any of the other categories.

lunch different activities?

Postby filankeshiata » Wed Aug 19, 2009 12:26 pm

Hello guys,

It seems that I've stuck on a problem that I cannot solve.
What I need is my program to start from the launcher in two different modes according to a preference the user has set - simple and advanced. I have one SimpleActivity which inherits Activity, and one AdvancedActivity which inherits TabActivity, so I cannot just start one Activity and give it the right layout, because they are initialised in very different way, and it also looks that I can neither call setContentView on a TabActivity, nor hide its TabWidget.

Any ideas?
filankeshiata
Freshman
Freshman
 
Posts: 2
Joined: Wed Aug 19, 2009 12:04 pm

Top

Postby Emmanuel7 » Wed Aug 19, 2009 6:42 pm

Can't you just have a launcher activity that just check the preferences and forward to the simple / advanced real activity ?
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Postby filankeshiata » Thu Aug 20, 2009 10:01 am

Emmanuel7 wrote:Can't you just have a launcher activity that just check the preferences and forward to the simple / advanced real activity ?


That was one option, but I chose to use GroupActivity, something like this:

Code: Select all
//onStart
//...
if (useSimpleActivity) {
     //clear what's left in the tabs if we change preferences
     if (mTabHost != null) {
         mTabHost.clearAllTabs();
         mTabHost = null;
     }
     setContentView(R.layout.simple_main);
} else {
     setContentView(R.layout.tabview_main);
     mTabHost = (TabHost)findViewById(android.R.id.tabhost);
     mTabHost.setup(); //XXX important
     mTabHost.setup(getLocalActivityManager()); //XXX important

     mTabHost.addTab(mTabHost.newTabSpec("tab1")
          .setIndicator("Indicator1").setContent(new Intent(this, SubActivity1.class)));
     mTabHost.addTab(mTabHost.newTabSpec("tab2")
           .setIndicator("Indicator2").setContent(new Intent(this, SubActivity2.class)));
    //... N tabs
}
filankeshiata
Freshman
Freshman
 
Posts: 2
Joined: Wed Aug 19, 2009 12:04 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 7 guests