ActionBar With Spinner (NAVIGATION_MODE_LIST) - android

In my app, I need an ActionBar with a dropdown on it (a spinner / setNavigationMode NAVIGATION_MODE_LIST). The ActionBar needs to be visible in all the views/screens of the app, but the content underneath it changes - it's a list of items that when clicked, a detailed view of the item is seen.
The ActionBar state should be persistent throught the different views (e.g. the selected item in the drop down).
What would be the correct way to do it? I can think of:
A base activity that initializes the ActionBar by calling actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST), attaching an adapter if needed etc. (How to persist the dropdown state?)
Using fragments
Another way?
Which of these ways is preferred?
Thanks

Related

Android actionbar search in a tabview

I am working with android fragments.I have a main activity and 3 fragments (tab1,tab2,tab3) in my app.Each fragment contains its own custom listview using base adapter.I want implement action bar search view in each fragment.I can do it using edittext search actions using setting editttext in each layout. But my question is is it possible to do it with actionbar searchview in each tab ?? If yes how can I detect which tab is currently selected or focused ?? and is it possible to do it with custom listview in fragment?? Please help me with some links or answer. Thanks in advance :)
Yes, the answer for all your questions its "yes".
You can use only one search box to filter all the listviews in all tabs / fragments. (I assume this is what you are trying to do)
TabHost has a method getCurrentTab() which returns the index of the tab that's in focus.
The content of the search bar (which is an EditText) you know now to which fragment to send. You can use this to filter the ListView.

Activity with variable content

I need to create an activity with an ActionBar, so that if you press the action bar buttons, the contents of the activity display the same information in different layout (one is a pie chart and the other a listview).
I don't want to use tabs or a viewpager, so what would be the best way to do this?
Build each view in a separate fragment, and use the actionbar buttons to set the current visible fragment.

Android: How do I make the ActionBar.OnNavigationListener being called for every item?

In my app, I want to use an ActionBar Spinner for navigation, although I know that this is not really the purpose of the Spinner. My problem is, that the first item in the Menu list is selected automatically when the Activity is started and a click on this first item doesn't trigger the Listener, as long as the first item is "active". What is the best and least hacky way to implement a fully working navigation menu looking exactly the same as the Spinner menu of the Actionbar? (i.e. with this small arrow on the bottom right etc.)

Android - ActionBar when splitscreen (List/Detail)

I am new to fragments and Ive been wondering whats the correct answer to this.
I am having simple List > Detail type of application, where this was originally 2 activities, no fragments, each had their own actionbar (menu).
Now I want to migrate it to fragments.
Using fragments I created a classic tablet split view with list on the left, detail on the right. Obviously that being only one activity, only the list's actionbar (action items) is being displayed.
Where should I put the action items from the detail? What the correct pattern? Should I create an alternative resource folder with custom menu file for tablets which would consist of both list's and detail's menu items?
Thanks !
Just create a new fragment_details.xml for the details fragment's menu entries.
Inflate the menu directly from the fragment.
Inflate the base menu from the list fragment.
The activity should have no menu attached at all as all menu entries are attached to the one or the other fragment.
In the tablet case, android will merge the fragment's menu with the one from the list fragment.
On smaller screens, when only the details are shown, the fragment's menu is shown.

in android can i change the action bar window feature at runtime?

ideally i'd like my main activity to have 2 views rather than starting a new activity; currently i'm using a view switcher to switch from map view and list view.
on my map view i want a transparent action bar.
on the list view i want a solid one (so the list items aren't inaccessible under the action bar).
is this something that is possible?
or am i forced to create 2 seperate activities and pass a list of custom objects through a bundle to make the transition between views as simple as possible.
the final goal is to have a iPhone style flipper animation when switching the views so it's like you're viewing the current stats/details on the back of the map view.
apparently such a transition animation might not be possible between activities, but i'm still looking into it.....
You can use actionBar.show() and actionBar.hide() to toggle ActionBar feature.

Categories

Resources