TabHost找不到addFlags()

时间:2012-03-01 20:37:08

标签: android refresh android-tabhost

我没有找到方法addFlags,skd是2.1

tabHost.addTab(tabHost.newTabSpec("tab1")
    .setIndicator("First Text")
    .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
    .setContent(new Intent(this, class1.class)));
tabHost.addTab(tabHost.newTabSpec("tab2")
    .setIndicator("Second Text")
    .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
    .setContent(new Intent(this, class2.class)));

谢谢!

1 个答案:

答案 0 :(得分:4)

Intent类有addFlags方法。认为您的代码应如下所示:

tabHost.addTab(tabHost.newTabSpec("tab2")
    .setIndicator("Second Text")
    .setContent(
      new Intent(this, class2.class)
          .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
    ));