Search code examples
androidandroid-fragmentsandroid-actionbarandroid-tabhostandroid-tabs

Should use Android tabhost or android action bar tabs based on requirement


I have recently started on android application development and developing my first app. I want to develop a tab based interface. I don't need to use compatibility lib. for older versions.

I want to have interface like this:

enter image description here

I know that tabbed activity is something which is something deprecated. So now I am left with two options I know. Actionbar tabs (http://developer.android.com/guide/topics/ui/actionbar.html#Tabs) or tab host with tab widget as shown in example here: http://android.codeandmagic.org/android-tabs-with-fragments/

At the end of this article, I read that this way is outdated and action bar tabs is recommended way. But in my case other than tabs I have two requirements:

  1. I need another common area in activity rather than those tabs. I am not sure if action bar tabs way i can have that common area as well. Area in image with edittext is place, i am talking about.
  2. I need to communicate between two tabs and parent activity.

So my question is that which way I should work? Tab host with tab widgets or action bar tabs. Or I am thinking wrong and there is some other better way I can achieve this thing. This common area will be sort of log area, where different actions will be inserted and it will be scrolled downward.


Solution

  • I don't need to use compatibility lib. for older versions

    The Android Support library has many, many things that are not "for older versions". Quoting the documentation:

    The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs.

    This has been the case for about four years.

    I know that tabbed activity is something which is something depreciated

    Action bar tabs were also deprecated, as of last year and the Android 5.0 release.

    So my question is that which way I should work? Tab host with tab widgets or action bar tabs.

    Probably neither. Use TabLayout, FragmentTabHost, or any of the many third-party libraries that add tabs to a ViewPager.

    Of the two that you cite, TabHost with views for tabs is the only currently supported approach.