How to create a tab in Android 4.0?

Now that TabActivity is out of date, what is the right way to create a tabbed interface using fragments? Each tutorial I have seen uses a different approach. Some of these are highly complex, pushing the mundane theme of programming into rocket science. What gives?

I am encoding ICS Android 4.0.

Thanks.

+7
source share
1 answer

Now it is preferable to use the tabs that the ActionBar gives you. It's pretty easy to set up considering you like this option. With ActionbarSherlock, you can even fully port an application to 1.6.

This is not suitable for every occasion. For example, you may want these tabs to be inside a fragment, on a screen that displays several fragments at once. In this case, you need to stick to the "obsolete" methods for setting tabs using TabWidget. It is ugly, but possible.

Edit:

Check out Jeff's comment. As he noted, I was wrong, TabWidget still works fine, TabAvtivity is an obsolete class here!

+2
source

All Articles