I want to show tab in my fragment but not on Action Bar?
Is this possible, any link or code might help??
Thanks in advance
I got the tabs without the rest of the ActionBar by removing the home button and the title, like this:
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
and not overriding:
onCreateOptionsMenu
That way the ActionBar would be empty and Android won't display it.
You can use the tabWidget. In a part of my application, I have a TabActivity where the inner activity uses fragments. So, it is possible. It may not be the best solution, but I had to do what the customer wanted.
It depends what kind of tabs you want to use. In my app I'm using ViewPager together with indicator and it works great, so maybe it will suite you. I hope I've understood your question.
Related
I have a small Android App which consists of 12 activities. I have also used SherlockActionBar for all the activites.
I want to add Navigation Tabs in action bar of one of my activity. I have done some googling but got to know that Navigation Tabs in ActionBar are used with Fragments.
So, my question is, how can I add Navigation Tabs to Action Bar without going for Fragments. I am not familiar with fragments and so don't want to use that.
Pease help me out here?
Thanks in advance.
StackOverflow is a better resource than google search for android (just my opinion). Perhaps this solution will meet your needs:
Is it possible to display tabs without using fragments in android 3.0?
I want to implement app which will download data and set it into ActionBar Tabs. I've already implemeted it, but I have one more thing to do. I've tried to add actionbar list, like this one, but android doesn't allow to use Tabs and List at the same time :( After pressing on one of the items in List, application should download corresponding data and fit it into my app. (Example) So how could I do that? Is there any way to fit spinner in Action Bar? if yes, please provide example.
I could do it this way:
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
navigation is tabs, but the ActionBar has a custom view.
bar.setCustomView(R.layout.custom_actionbar);
bar.setDisplayShowCustomEnabled(true);
That custom_actionbar contains the spinner.
How can i archive a Tab layout like this in Android ? The Tab Navigation is part of that
Main ActionBar and is not below. PS: Im using ActionBar Sherlock
At the moment is just do:
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
But i want a look like this:
Thanks for help,
Kitesurfer
I don't recommend doing this but you could override the ActionBar and ABS styles:
<bool name="abs__action_bar_embed_tabs">false</bool> //for ActionBarSherlock
<bool name="action_bar_embed_tabs">false</bool> //for default ActionBar
Tab will be displayed in actions bar but only if action bar has space. When you are in landscape mode your tabs will move to action bar because in landscape mode action bar has more room.
From this thread. On the topic of overriding the Action Bar tab functionality.
Jake Wharton
I am obligated to tell you this is probably a Bad Idea™ and I don't recommend it. When you fight the platform you almost always end up losing.
I am inclined to agree about fighting the platform. Instead I opted to abandon the stock tab navigation (from both the android platform and ABS library) and instead wrote a layout that looks basically the same as the tabs, and used it as a custom view, applying it using ActionBar.setCustomView(View) and ActionBar.setDisplayShowCustomEnabled(true) methods.
This uses the ActionBar api in the standard way (ie. Not fighting the platform) and, as is pointed out in that thread, the tab view is simply a LinearLayout.
Try this. This implements a method that will let you select whether you want the tabs in a separate row or in the top row, regardless of screen orientation.
For those who are using this code with the native ActionBar, simply omit the if (actionBar instanceof ActionBarWrapper) and the block underneath it.
Bear in mind, though, that this is somewhat of a hack and might break in future Android versions.
Does anyone of you know of a sub navigation pattern in Android that uses a tabbed ActionBar navigation with pageable Fragments for its main navigation? (ViewPager)
I have looked at Spinners in the ActionBar which could work quite well if it wouldn't take ages to get the submenu rendered in the ActionBar while swiping from one tab to the next. (in the end you have jumping action items which look pretty ugly)
The other approach would include a segmented control widget which is known from the iOS platform. (like the TED application has it at the moment)
But what would be the Android way of doing it?
Why can't you try menu's for different tabs? I dont know whether it helps or not.Surf google for creating menus for each tab.
There is a situation in which I want to use Tab bar as well as List navigation, Both at same time in Action bar.
Documentation says 'we can put Actionbar in to list navigation mode or tabs navigation mode'.
Is there any way to use both at same time. Any pointers, help. Thank you in Advance.
Sorry, you can only have one or the other.
That being said, you can use android:actionLayout to convert an options menu item into a custom inflated layout in the action bar. You might be able to use the "tabs navigation mode" while putting your own Spinner to the right of the tabs this way. Personally, I would find this confusing as a user, but perhaps it will work for your use case.
a very late answer, but this is possible by a simple hack. You just have to replace (programatically) the view that is pointed by android.R.id.action_bar_title with a Spinner. I wrote a blog about it. Here's the link