谢谢你查看我的询问!
我已经实现了一个标签环境,如下图所示.它似乎按照我的预期工作,除了它永远不会执行onTabChanged方法.我找到了几个关于这种情况的帖子,但是无法让我的代码以我预期的方式工作.建议吗?
谢谢,芯片
public class TestTabActivity extends TabActivity implements OnTabChangeListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
intent = new Intent().setClass(this, Page1Activity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = tabHost.newTabSpec("page1").setIndicator("Page 1",
res.getDrawable(R.drawable.ic_tab_page1))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, Page2Activity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
spec = tabHost.newTabSpec("page2").setIndicator("Page 2",
res.getDrawable(R.drawable.ic_tab_page2))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, …Run Code Online (Sandbox Code Playgroud)