I've been trying to setup a ViewPager with tabs in the ActionBar, but I also wanted to support older API levels (pre-ActionBar levels).
Since nearly everything that I'm trying to do in order to setup the tabbed ViewPager requires API level 11 and I can only seem to get the support libraries to go so far, I'm unsure as to what I should do.
I know I could use a TabWidget with a HorizontalScrollView to get the job done, however I don't think it will be efficient enough, nor provide the same user experience/usability/interaction, right?
or
Should I use the Sherlock Action Bar?
Sherlock Action Bar is recommended for using ActionBar in API < 4.0 not only for ViewPager movements it provides navigation like "Up" button and actionItems behaviour also if you need to in future migrate the app to support apis >= 4.0 the changes are very very little.
Related
Since setNavigationMode has been deprecated in API level 21 what can I use instead of setNavigationMode to create tabs.Is there an alternative library which I can use.
Action bar navigation modes are deprecated in API level 21.
So, it is not just setNavigationMode but other stuff related to Action Bar such as addTab(), selectTab(), too are deprecated.
Other possible Alternatives:
1. PagerTabStrip: This is part of Android support library, and It is intended to be used as a child view of a ViewPager widget in XML layout.2.Toolbar: Added in API Level 21, is a new class android.widget.Toolbar. As per Android docs, A Toolbar is a generalization of action bars for use within application layouts.
ToolBar is a view placed in your view hierarchy that provides a similar, but more focused, API to the action bar.
An application may choose to designate a Toolbar as the action bar for an Activity using the setActionBar() method.
It depends on your app design as to which one you may want to choose as vis-a-vis replacement.
Check THIS Link for more info.
I want to support api level 9 and still using fragments and tabs. Therefor I have used sherlock action bar and it works fine. Now, in one of my tabs (all tabs are fragments) I want to have a settings screen for creating a new game. I figure preferences is the best choice. BUT I don't know how to use preferences in a fragment and still support api level 9. Can anyone please help?
If it's not possible to use preferences in fragment and support api level 9, do you have any suggestions? How can I for example create views to look like a preference, that is, text to the left, checkbox to the right and when I check it, the whole layout gets selected? And a radiobuttongroup with the same look?
I'm having a bit of a problem with the Android tab layout. I've been trying to make a screen that holds 4 tabs, and a fragment beneath them, when a user presses each tab the fragment dynamically switches to another activity and the tabs stay static, my problem is that I tried to implement it with tab layout and it's deprecated in since Android 4.0, so I tried it with the action bar tabs but then I have the action bar that I don't want nor need.
I have two questions:
Is it possible to use action bar but to hide the action bar and show only the tabs?
Is there a way to use tab layout on Android 4.0 and higher versions?
1.Yes there is possibility.....you should try http://actionbarsherlock.com/
2.ActionBarSherlock works from sdk 7 to sdk 16
I am not really sure about whether you can achieve it or not but if you want to play around with the ActionBar, this would be one of the best places to start.
Just because it is deprecated, doesn't mean that you can't use tabs in Android 4+. ;)
You surely can use Tabs and TabLayout in Android 4+ and everything works perfectly(though you apparently should not as ActionBar is a must better option).
I have tried it myself because even I prefer the TabLayout more than the ActionBar, and thankfully haven't run into any issues until now!
The only thing you will notice is that Eclipse will draw a yellow line over the deprecated code (which you can obviously ignore or just choose to hide all deprecated warnings).
I'm not sure what direction to take with a Tabbed layout.
I am targeting sdk 15, min sdk 11. Are tabs better left in the action bar or in the "body". I am not designing for tablets with this app (yet), but it seems tablets have tabs in the Action bar and smaller screens do not.
One of the main reasons why I ask is because Google does have some info on tabs here:
http://developer.android.com/design/building-blocks/tabs.html
But I can't seem to find it in their new "Develop" section. So I don't know if this has been deprecated? There used to be a good example on Tab layouts.
You can still use them. They are not deprecated. In the post android 3.0 versions the tabs have been placed in the action bar on tablets. on phones they are below the action bar in portrait and again in the action bar in landscape. it's is considered a good practice to follow those standards as android developer suggests. Now i haven't used the new implementations but rather a compatibility library called ActionBarSherlock. it is actually pretty good and its almost exactly the same in terms of usage as the regular tabs. you can find some good samples on how to implement what you need in there.
Also i am pretty sure you can find all the samples in your android sdk folder under samples/android-14 for example.
I always felt that its easier to browse through them from there as opposed to developer.android.
Hope this helps you.
"If you use navigation tabs in your action bar, once the action items are separated on a narrow screen, the navigation tabs may be able to fit into the main action bar rather than be separated into the "stacked action bar." Specifically, if you've disabled the action bar icon and title (with setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false)), then the navigation tabs collapse into the main action bar."
http://developer.android.com/guide/topics/ui/actionbar.html
This is in fact part of the new design pattern.
If the tabs can fit into the main action bar, let them.
Usually if you're in portrait mode they wouldn't (except for the case stated in the above quote), but when you switch to landscape mode (or if you're on a tablet) they would easily fit.
Everything you find on the developer's site is recommended and is considered good practice. Further, the "design" and "develop" sections go hand in hand... the separation is not meant to imply that "only developers should look at 'develop'" or vice versa. You should treat each as equally important when writing your app.
So yes, it is recommended to implement your tabs with the action bar (as seen in FragmentTabs.java in the API Demos), and it is certainly not deprecated.
Or is there a close equivalent to making this control work pre-ICS?
I got ActionBar covered with ActionBarSherlock, but I'm not sure how to get TabBar working the same way...
There is no TabBar in any version of Android.
If you mean "tabs in the action bar", ActionBarSherlock supports that.