how to call an Activity through TabBars

后端 未结 1 1993
走了就别回头了
走了就别回头了 2021-01-25 07:00

I\'m making an application in which m using Tab Bars. Now what i need to know is, how to open other Tab through setOnTabChangedListener() in my code

for ex

相关标签:
1条回答
  • 2021-01-25 07:42

    see the below code

     TabHost tabHost = getTabHost(); // The activity TabHost
            TabHost.TabSpec spec; // Reusable TabSpec for each tab
            Intent intent; // Reusable Intent for each tab
    
            // Create an Intent to launch an Activity for the Movies tab.
            intent = new Intent().setClass(this, BarActivity.class);
            // Initialise a TabSpec for the Movies tab and add it to the TabHost.
            spec = tabHost.newTabSpec("Nights").setIndicator("Nights").setContent(intent);
            tabHost.addTab(spec);
    
            // Do the same things for the Theatres tab.
            intent = new Intent().setClass(this, BarActivity.class);
            spec = tabHost.newTabSpec("Weeks").setIndicator("Weeks").setContent(intent);
            tabHost.addTab(spec);
    
    0 讨论(0)
提交回复
热议问题