单击时如何进入第二个标签栏?是选择始终第一个标签栏我想在屏幕显示标签栏时选择第二个标签栏我的屏幕选择第一个标签栏
我想在这样开始时选择第二个标签栏
我的代码在
之下public class TabBarActivity extends TabActivity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
setTabs() ;
}
private void setTabs()
{
addTab("payments", R.drawable.tab_home, AgAppPaymentScreen.class);
addTab("My Account", R.drawable.tab_home, AgAppMyAccountScreen.class);
addTab("Spend Analyzer", R.drawable.tab_home, AgAppPaymentScreen.class);
addTab("Notification", R.drawable.tab_home, AgAppPaymentScreen.class);
addTab("Help", R.drawable.tab_home, AgAppPaymentScreen.class);
}
private void addTab(String labelId, int drawableId, Class<?> c)
{
TabHost tabHost = getTabHost();
Intent intent = new Intent(this, c);
TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId);
View tabIndicator = LayoutInflater.from(this).inflate(
R.layout.tab_indicator, getTabWidget(), false);
TextView title = (TextView) tabIndicator.findViewById(R.id.title);
title.setText(labelId);
ImageView icon = (ImageView) tabIndicator.findViewById(R.id.icon);
icon.setImageResource(drawableId);
spec.setIndicator(tabIndicator);
spec.setContent(intent);
tabHost.addTab(spec);
}
}
答案 0 :(得分:0)
tabHost.setCurrentTab(1);
0:第一个标签。 1:第二个标签。