I created an application with 3 tabs. The application works great, but I want the second tab to be selected and loaded when the application opens. How can i install this?
Here is my code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost tabHost = getTabHost();
TabSpec homespec = tabHost.newTabSpec("Home");
homespec.setIndicator("Home",getResources().getDrawable(R.drawable.icons_home_tab));
Intent photosIntent = new Intent(this, HomeActivity.class);
homespec.setContent(photosIntent);
TabSpec childspec = tabHost.newTabSpec("Child");
childspec.setIndicator("Child",getResources().getDrawable(R.drawable.icons_child_tab));
Intent homeIntent = new Intent(this, ChildActivity.class);
childspec.setContent(homeIntent);
TabSpec accspec = tabHost.newTabSpec("Account");
accspec.setIndicator("Account",getResources().getDrawable(R.drawable.icons_account_tab));
Intent accIntent = new Intent(this, AccountActivity.class);
accspec.setContent(accIntent);
tabHost.addTab(homespec);
tabHost.addTab(childspec);
tabHost.addTab(accspec);
}
source
share