1

在我的一个应用程序中,我在 {{tabactivity}} 和 {{activitygroup}} 的帮助下使用了一个标签栏来在每个屏幕上显示标签栏。

我想检测已经选择的选项卡上的第二次单击并实现类似于 iPhone UITabbar 的功能。在第二次单击时,它将进入初始活动。

public class Tabmanagement extends TabActivity{

public static Button back;
public static TextView text;
public static Button next;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.tabmanagement);

    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    Resources res = getResources();
    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec;
    Intent intent;

    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.windowstitle);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

    back=(Button)findViewById(R.id.Btn_Back);
    text = (TextView) findViewById(R.id.Text_Title);
    next=(Button)findViewById(R.id.Btn_Search);  


    spec = tabHost  .newTabSpec("tab1")
    .setIndicator("Topics",res.getDrawable(R.drawable.topics))
    .setContent(new Intent(this,FirstGroup.class)
    .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
    tabHost.addTab(spec);




    spec = tabHost  .newTabSpec("tab2")
    .setIndicator("Posts",res.getDrawable(R.drawable.post))
    .setContent(new Intent(this,SecondGroup.class)
    .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
    tabHost.addTab(spec);



    intent = new Intent().setClass(this, ThirdGroup.class);

    spec = tabHost  .newTabSpec("tab3")
                    .setIndicator("Response",res.getDrawable(R.drawable.response))
                    .setContent(intent);

    tabHost.addTab(spec);


    intent = new Intent().setClass(this, FourthGroup.class);

    spec = tabHost  .newTabSpec("tab4")
                    .setIndicator("Settings",res.getDrawable(R.drawable.settings))
                    .setContent(intent);

    tabHost.addTab(spec);
    tabHost.setCurrentTab(0);

    }

}
4

1 回答 1

0

我想这就是你要找的。基本上从 TabHost 中获取 TabWidget 并在视图上设置适当的侦听器。

如何检测对已选择的选项卡按钮的点击

于 2014-11-01T21:04:57.633 回答