4

My question sounds simple, but I can't seem to find a sufficient answer for this.

I'm trying to design an app for tablets that has some information at the top quarter of the screen, and then a tabbed menu for information below the top quarter.

Basically what I'm looking for is :

┌─────────────────────────────────────
│
│ Top of Page
│
├───────┬───────┬───────┬───────┬─────
│ Tab 1 │ Tab 2 │ Tab 3 │ Tab 4 │
│       └───────┴───────┴───────┴─────
│
│ Bottom of page
│
│
│
⁞

I was originally going to use a tabhost with multiple tabs; but I realize that it's deprecated now, and so I'm looking for the most efficient, and up-to-date method for doing this for Android development. The easiest thing already implemented would be the action-bar, but that's at the top of the app -- and that's not quite what I'm trying to go for either.

I read on another thread that Fragments should be used instead; but considering the simplicity of tabhosts, I don't quite see how a fragment can replace this because, so far as I can tell, it doesn't have a built-in tab option; only lists. (Of course I may be wrong)

The other options I have found were ActionbarSherlock, and just using buttons that change layouts.

I guess overall what I'm asking is, what is the best, most up-to-date backwards-compatible way to reproduce the design I have up there?

EDIT: So far the only thing I have found from researching is still stating that I use fragments with the compatibility API, or simply using buttons and a FrameLayout. I'm really not interested in using the action-bar, as it does not go below the layout that is supposed to be on the top.

Or would it really be so bad to just go ahead and use the TabHost anyway, even though it's deprecated?

Human-Compiler
  • 11,022
  • 1
  • 32
  • 59

2 Answers2

0

CMIIW but i think tabhost is not deprecated yet. even if it's deprecated, it doesn't mean that you can't use it, it just mean that there is better alternative. Go for Tabhost if you think you really want and comfort to use it.

for alternative way, you can take a look at this : alternative of tabactivity or this if you go for better understanding in using Tabhost how do i use tabhost.

alternative ways including: Use a ViewPager with a tabbed indicator, such as PagerTabStrip, the TabPagerIndicator from the ViewPagerIndicator project, PagerSlidingTabStrip, etc.

Use tabs in the action bar (note: these will convert into a drop-down list in some device sizes and orientations)

Use FragmentTabHost

Use TabHost and TabWidget in a regular Activity

The following sample projects demonstrate:

PagerTabStrip: https://github.com/commonsguy/cw-omnibus/tree/master/ViewPager/TabPager

TabPageIndicator: https://github.com/commonsguy/cw-omnibus/tree/master/ViewPager/VPI

action bar tabs: https://github.com/commonsguy/cw-omnibus/tree/master/ActionBar/TabFragmentDemo

TabHost and TabWidget: https://github.com/commonsguy/cw-omnibus/tree/master/WidgetCatalog/Tab

Note that the first three samples all use ActionBarSherlock, so they run on Android 2.x devices. The fourth one should run on anything from Android 1.0 onwards.

Community
  • 1
  • 1
ganero
  • 91
  • 1
  • 2
  • 16
-2

You can use:

Action Bar in android

Akhil Sekharan
  • 12,467
  • 7
  • 40
  • 57