Is it possible to have both, an spinner/dropdown at the top and tabs just below in the action bar? I want to use the spinner at the top of the action bar as view-switch controller (i.e. table view or chart view) while the tabs below is going to show different lists of data.
The following screen shot illustrates exactly what I want to achieve:
If it's not possible having both modes in the action bar, I could put an TabWidget at the top of my content view. However, I'm little bit unsure if I should have one fragment or one activity per tab.
It's possible. I was trying to achieve an identical UI to what you have shown, and was stuck until I tried something pretty simple but a bit confusing as well.
What I've done is set a Spinner as my custom view for the ActionBar, and then:
ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
Here's an example of what I mean.
Tabs Code:
In the parent activity for this activity, I've done this:
This effectively makes gives me a custom view for the ActionBar, but then I can set the navigationMode to tabs to allow me to have the tabs I want. Set the appropriate event listeners on each item, and voila!
You can also create a custom action provider to achieve a spinner in the action bar. So there is no need to create a whole action bar. By doing this and use tabs as navigation mode your goal is fulfilled.
Not possible in default lib using bat you can create custom action bar view and set that one possible
try this one code
BaseActivity.java
ViewActivity.java
TabListener {
EDIT:
No. The code in ActionBarView (where the setNavigationMode(int) call ends up) uses a switch statement, so the modes can't be combined.
Some combination of the action bar navigation modes and my previous answer is still a valid option though: You could use a custom view in your Action Bar and use a ViewPager for the content. Each tab in the ViewPager would be a fragment that you can update manually (change the view type) from the parent activity when the spinner is changed.
Side note, there are 3rd party libraries such as ViewPagerExtensions that give the fixed tabs appearance without having to use the ActionBar tabs.