Java 如何确定当前选定的选项卡?

Java 如何确定当前选定的选项卡?,java,android,tabs,android-intent,android-tabhost,Java,Android,Tabs,Android Intent,Android Tabhost,我有一个TabHost,它有两个选项卡。每个选项卡都有自己的用途: TabHost.TabSpec spec; // Resusable TabSpec for each tab Intent intent; // Reusable Intent for each tab // Create an Intent to launch an Activity for the tab (to be reused) intent = new Inte

我有一个TabHost,它有两个选项卡。每个选项卡都有自己的用途:

TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, ARActivity.class);

        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("trending").setIndicator("Trending",res.getDrawable(R.drawable.icon)).setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, WatchlistActivity.class);
        spec = tabHost.newTabSpec("watchlist").setIndicator("Watchlist",res.getDrawable(R.drawable.icon)).setContent(intent);
        tabHost.addTab(spec);

        tabHost.setCurrentTab(0);

当我处于活动状态或WatchlistActivity状态时,如何确定选择了哪个选项卡?

您好,您可以使用这两个活动的tabHost.getCurrentTab()onResume()来检测您选择了哪个选项卡

Hi您可以使用这两个活动的tabHost.getCurrentTab()onResume()来检测您选择的选项卡