2

So I have an Android app that is running in a TabActivity that separates 6 different activities through its tabs. Since TabActivity is deprecated since HoneyComb, and as far I as read I've to use fragments.

Have I to transform all that 6Activities into fragments if I want to use action bar with tabs, right? Where should I start to rewrite all my activities into fragments?

Luis Neves
  • 1,067
  • 2
  • 10
  • 21
  • 1
    Without writing a full and comprehensive answer to your question, no, you don't have to use the Action Bar (though maybe you should.) The docs for [TabActivity](https://developer.android.com/reference/android/app/TabActivity.html) have an example of using the new TabHost and see also the Fragment Tabs Pager example. That's what I'm using. – David Snabel-Caunt Dec 11 '12 at 18:01
  • 1
    @DavidCaunt: There is also the new `FragmentTabHost`, though it is under-documented and I had difficulty getting it to work. Though, personally, I'd prefer to use `ViewPager` and a tab implementation for it (e.g., `PagerTabStrip`) -- all the benefits of tabs, plus horizontal swiping as an option. – CommonsWare Dec 11 '12 at 18:15
  • 1
    @CommonsWare Agreed, I'm using ViewPager as in the [Fragment Tabs Pager](https://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabsPager.html) sample (no longer available online it seems - see SDK Samples). I think it comes down to whether you want tabs or a title strip but you're right, you can use either. I guess the message to Luis is that they're loosely coupled and there are lots of options! – David Snabel-Caunt Dec 11 '12 at 18:24
  • but in the end all the solution you have talked I've to transform my activities in to fragments, right? – Luis Neves Dec 11 '12 at 18:52
  • 1
    Yes - it shouldn't be too much work though. You can use your activity layouts in the new fragments, and move most of your code from the activity to the fragment. The end result is not only much faster and smoother UI but also more maintainable and re-usable code. – David Snabel-Caunt Dec 11 '12 at 22:38

0 Answers0