How to implement Android tab menu without obsolete taboo

My question sounds simple, but I cannot find a sufficient answer for this.

I am trying to create an application for tablets that have some information in the upper quarter of the screen, and then a tabbed menu for information below the upper quarter.

I am mainly looking for:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ β”‚ Top of Page β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€ β”‚ Tab 1 β”‚ Tab 2 β”‚ Tab 3 β”‚ Tab 4 β”‚ β”‚ └───────┴───────┴───────┴───── β”‚ β”‚ Bottom of page β”‚ β”‚ β”‚ ⁞ 

I originally intended to use tabhost with multiple tabs; but I understand that it is out of date now, so I'm looking for the most efficient and modern way to do this for Android development. The easiest way that has already been implemented is the action bar, but at the top of the application - and this is not quite what I also want to go to.

I read in another thread that fragments should be used instead; but given the simplicity of tabhosts, I don’t quite understand how a fragment can replace this because, as far as I can tell, it does not have a built-in tab option; only lists. (Of course, I could be wrong)

Other options I found are ActionbarSherlock and just buttons that change layouts.

I assume that overall what I am asking is the best, most modern way of backward compatibility with the reproduction of the design that I have there?

EDIT: So far, the only thing I've found from the study still states that I'm using fragments with the compatibility API or just using the buttons and FrameLayout. I'm really not interested in using the action bar, since it does not go below the layout, which should be on top.

Or would it be really bad if you just go ahead and use TabHost anyway, although it's deprecated?

+4
source share
2 answers

CMIIW, but I think tabhost is not out of date yet. even if it is out of date, it does not mean that you cannot use it, it just means that there is a better alternative. Go to Tabhost if you think you want and want to use it.

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

alternative methods, including: Use a ViewPager with a tabbed indicator, for example, PagerTabStrip, TabPagerIndicator from the ViewPagerIndicator project, PagerSlidingTabStrip, etc.

Use the tabs on the action bar (note: they are converted to a drop-down list in some device sizes and orientations)

Use FragmentTabHost

Use TabHost and TabWidget in normal action

The following project examples 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 use ActionBarSherlock, so they run on Android 2.x devices. The fourth should work on anything since Android 1.0.

0
source

You can use:

Android action bar

-2
source

Source: https://habr.com/ru/post/1447643/


All Articles