我在android工作 . 我使用了tab主机和tab小部件 . 我有4个活动要添加为视图 .
这是我的计划:
public class TabDemo extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost=getTabHost();
// no need to call TabHost.Setup()
//First Tab
TabSpec spec1=tabHost.newTabSpec("Tab 1");
spec1.setIndicator("Tab 1",getResources().getDrawable(R.drawable.sun));
Intent in1=new Intent(this, Act1.class);
spec1.setContent(in1);
TabSpec spec2=tabHost.newTabSpec("Tab 2");
spec2.setIndicator("Tab 2",getResources().getDrawable(R.drawable.chart));
Intent in2=new Intent(this,Act2.class);
spec2.setContent(in2);
tabHost.addTab(spec2);
tabHost.addTab(spec3);
}
}
现在在第二个Activity中,我想在按钮点击上更改此文本“Check-In” .
spec2.setIndicator("Check-In",getResources().getDrawable(R.drawable.chart));
如何在子类中更改超类的setIndicator文本?
如果您有任何其他与我的问题相关的问题,请随时询问 .
1 回答
您可以在按钮单击时发送广播意图,并使用tabhost在活动中监听此意图 .