Issue
I currently have Tab Based app and the tabs are on bottom. Is there any way to put them up?
Solution
To create tabs using ActionBar, you need to enable NAVIGATION_MODE_TABS, then create several instances of ActionBar.Tab and supply an implementation of the ActionBar.TabListener interface for each one. For example, in your activity's onCreate() method, you can use code similar to this:
@Override public void onCreate(Bundle savedInstanceState) { final ActionBar actionBar = getActionBar(); // Specify that tabs should be displayed in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create a tab listener that is called when the user changes tabs. ActionBar.TabListener tabListener = new ActionBar.TabListener() { public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { // show the given tab } public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { // hide the given tab } public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { // probably ignore this event } }; // Add 3 tabs, specifying the tab's text and TabListener for (int i = 0; i < 3; i++) { actionBar.addTab(actionBar.newTab().setText("Tab " + (i + 1)).setTabListener(tabListener)); } }
How you handle the ActionBar.TabListener callbacks to change tabs depends on how you've constructed your content. But if you're using fragments for each tab with ViewPager as shown above, the following section shows how to switch between pages when the user selects a tab and also update the selected tab when the user swipes between pages.
From Docs.
Answered By - Mayank Bhatnagar
Answer Checked By - Mildred Charles (JavaFixing Admin)