¿Cómo crear un diseño con pestañas en Android 4.0?

Now that TabActivity is deprecated, what is the proper way to build a tabbed interface using fragments? Every tutorial I have seen takes a different approach. Some of them are supremely complicated pushing a mundane programming topic to the rocket science territory. What gives?

I am coding for ICS Android 4.0.


preguntado el 08 de noviembre de 11 a las 16:11

If you want tabwidget with fragment this tutorial might help you learnncode.wordpress.com/2013/12/18/… -

1 Respuestas

The preferred way now is to use the tabs that ActionBar gives you. It's quite easy to set up, given that you like this option. With ActionbarSherlock, you can even port your app all the way back to 1.6.

It's not suitable for every case however. For example, you might need those tabs to be inside a fragment, on a screen that displays multiple fragments at once. In that case, you have to stick with the "deprecated" methods to set up the tabs, using a TabWidget. It's ugly, but possible.


Check Jeff's comment. As he pointed out, I was wrong, TabWidget is still perfectly valid, TabAvtivity is the deprecated class here!

Respondido el 17 de Septiembre de 12 a las 11:09

Thanks. I got tabs working with ActionBar. This document was very useful: abelski.com/courses/android3ui/actionbar.pdf - RajV

TabWidget is not deprecated, TabActivity is. The action bar is no necesariamente preferido, it depends upon the use, as answered by Adam Powell Android platform navigation expert. - Jeff Axelrod

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.