I have two tabs for two activities in my TabHost(MainActivityTabs).My problem is when i try to open the second activity from the first one using intents , the TabHost looses its view ,meaning a can't see the two tabs on the bottom and the second activity is on the full screen.
~The main activity ~
public class MainActivityTabs extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_tabs);
Resources ressources = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent().setClass(this, First.class);
spec = tabHost
.newTabSpec("First")
.setIndicator("",
ressources.getDrawable(R.drawable.search))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, Second.class);
spec = tabHost
.newTabSpec("Second")
.setIndicator("", ressources.getDrawable(R.drawable.favorites))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(2);
}
}
~first class ~
public class First extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.first);
Intent intent = new Intent().setClass(this, Second.class);
int i =1;
intent.putExtra("somthing", i);
startActivity(intent);
}
}
~Second class~
public class First extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sec);
}
}