I have 4 tabs in a page view when i click first time on tab it executes it oncreate() method of corresponding tab and when i go to other tab on same page and again click on previous clicked tab then its oncreate() method not execute why?why it is not work as button click means each time i click its oncreate() method run.
my code for tab activity class is below
intent1 = new Intent().setClass(this, keywordxmlparsing.class);
spec1 = tabHost.newTabSpec("Activity2").setIndicator("keyword/ search...").setContent(intent1);
tabHost.addTab(spec1);
intent2 = new Intent().setClass(this, filter.class);
spec2 = tabHost.newTabSpec("Activity1").setIndicator("filter search").setContent(intent2);
tabHost.addTab(spec2);
intent3 = new Intent().setClass(this, OpeningToday.class);
spec3 = tabHost.newTabSpec("Activity3").setIndicator("opening today").setContent(intent3);
tabHost.addTab(spec3);
intent4 = new Intent(keywordresulttab.this,Map.class);
spec4 = tabHost.newTabSpec("Activity4").setIndicator("Map").setContent(intent4);
tabHost.addTab(spec4);
dear if i use
@Override
public void onTabChanged(String label) {
// TODO Auto-generated method stub
if(label == "Activity2") {
}
try{
if(label == "Activity4") {
Intent intent4;
intent4 = new Intent(keywordresulttab.this,Map.class);
startActivity(intent4);
Log.i("suiuawhd","maps class");
}
then can i go to other activity means using
intent4 = new Intent(keywordresulttab.this,Map.class);
startActivity(intent4);
we can load again activity on tab click??then what to written in place of
tabHost.addTab(spec3);
intent4 = new Intent(keywordresulttab.this,Map.class);
spec4 = tabHost.newTabSpec("Activity4").setIndicator("Map").setContent(intent4);
tabHost.addTab(spec4);
Tabs that contain activities are implemented by means of ActivityGroup. When someone changes a tab, corresponding activity is created only if necessary. When you move to any tab for the second time, the activity is already existing and only its window is shown.
You should use instead:
TabActivity with separate activities as a content are a little bit tricky so maybe you should consider using Views instead. If not you can use the following code to access all activities from each other:
get instances of content activities from TabActivity:
where name is given in newTabSpec() method.
get instance of TabActivity from content activities:
Using these method you can create communication between all activities (using proper casting). For example:
If you want to change activities under tabs you should use:
and create all TabSpecs once again.