Top tabs, bottom tabs and action bar tabs in android - android

I am developing an android application which is the android version of existing iphone app.
In iPhone app, there are five bottom tabs (As iOS support these). Every tab has more than one activities.
For example:
Tab 1: It has activity 1 which starts activity 2 and so on with in the single tab (Tab 1) and also back navigation too.
I have already read following but still have doubts.
http://developer.android.com/design/patterns/pure-android.html
http://developer.android.com/design/patterns/actionbar.html
http://developer.android.com/guide/topics/ui/actionbar.html
My questions are:
1) What is the best replacement of such kind of tabs in android. If I use action bar tabs then It will the right approach?
2) If I use action bar tabs, then is it possible to start different activities with in the single tab and action bar back navigation too?
3) When I should use Action bar tabs, Top tabs or bottom tabs in android (Tab Host still not deprecated in the Android)
Please guide me. I am very confused about tabs in android.

1) You can use Navigation Tabs! (and With that probably you'll use Fragmnets and not Activity)
2) Of course, the Navigation Up is really an usefull thing
3) Bottom tabs is possible with a Custom Layout.. I think it's not best thing, but you can do it!
It's a very short anwser but you can check everything in developer training and checkin samples that you find in your SDK

Related

Android Airbnb like Tabs

I am trying to figure out how airbnb has implemented its Tab Bar, it either seems they have hidden their actionbar and everything has been shifted onto a tab bar but then the right most user icon opens the navigation drawer which should be ideally on actionbar, Or everything is on action bar itself but then how can those 3 tabs/icons on left be implemented on actionbar. (Kindly refer attached image)
Can somebody put some light on how this can be implemented. How to go about it? Also are those 3 icons fragments or separate activities?
Here, is a library which makes your life simpler to implement TabBarView for actionbar tabs.
https://github.com/Mirkoddd/TabBarView
This should give you insight about how to use it for your app.

Slidable tab navigation depending on the screen size

I am looking for a Tab navigation UI component that would work similarly to the SlidingPaneLayout, i.e. would show as many tabs as possible and make the tabs slidable left/right when the tabs wouldn't fit on the screen (in my case its tablets vs smartphones case). An example of it would be Slideable top navigation UI pattern.
Is there any library I could use to implement such component in my app?
Action bar tabs and ViewPager are the one's you are looking for. These are in built feature of Android, Easy to access and backward compatible to earlier versions as well.
ActionBar tabs is the one that will give you the tab like feature.
ViewPager on the other hand will provide the functionality of swipe.
Here is a step by step example on both.

How to structure code for Activitys in a tabhost and actionbars

I want to have a few pages under a tabhost. The pages with the tabs, are accessed on about page 2/3 after application start. I am confused in how to link to the first page of the tabhost (from a page without a tabhost)
Each tab in the tabhost is a separate activity.
So when it's time to send user to a page in the tabhost, do I start the Tabhost activity (from extends TabActivity), create the tabhost, then... somehow choose which page in the tab to load? like tabhost.myTab.trigger.start(); INSTEAD of just loading one of the tabs activities directly..
So therefore anytime you leave the tabhost, and come back to it , you are recreating it, is this the correct way to structure things?
Thanks!
The TabHost method is considered a pretty old way of creating tabs within your Android application. This is especially so if you're placing Activities within those tabs.
A modern Android application uses Fragments, and uses the Action Bar framework to place those Fragments within tabs.
This can be done easily from your main Activity by using
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
This has several advantages. It means your Fragments can be placed inside of a ViewPager (so the user can swipe between them). It also means that your tabs will adapt to the device they're running on. (On a phone they may appear below the Action Bar, but on a tablet they actually become part of the Action Bar).
Depending on your implementation, this can be done is such a way that navigating between tabs does not cause the Fragments to be recreated (if that's what you're after).
A detailed guide on how to implement Action Bar Tabs can be found here
If backwards compatibility is a concern, then check out the amazing Action Bar Sherlock library.
I don't fully understand the behavior you are trying to accomplish.
Though, if you don't want to reinvent the wheel, i would recommend you to install the ActionBarSherlock demo apps1 to check if the desired behavior is already implemented as one of the library examples. If it's already done, then you can go to the github project to take a look at the source code, learn how it's done, and contribute with it.
Action Bar Sherlock demos
https://play.google.com/store/apps/details?id=com.actionbarsherlock.sample.demos&hl=en
Action Bar Sherlock Fragment demos
https://play.google.com/store/apps/details?id=com.actionbarsherlock.sample.fragments&hl=en

Using both list navigation and tabs with ActionBarSherlock?

I'm looking through the ActionBarSherlock samples demo, and I see that the List Navigation and the Tab Navigation both make use of the ActionBar's setNavigationMode method. This tells me that you can only have one or the other. If I want the user to have list navigation to move around between activities but I want some activities to have tabs, is there a different way to add tabs than via navigation mode? Is it against ActionBar design guidelines to use both? I don't look at tabs and consider this to be a navigation feature, so I find it odd that you get one or the other.
This tells me that you can only have one or the other
Correct. Bear in mind that with action bar tabs, Android will convert you to list navigation, on its own, in certain configurations, whether you like it or not.
If I want the user to have list navigation to move around between activities but I want some activities to have tabs, is there a different way to add tabs than via navigation mode?
You can use a ViewPager with PagerTabStrip or the tab flavor of ViewPagerIndicator.
Or, you can go retro and use TabHost and TabWidget.
Is it against ActionBar design guidelines to use both?
The design guidelines refer to them as separate options for "View Controls". More importantly, given the automatic conversion of tab navigation to list navigation, it would be seriously confusing for the action bar to have two Spinners' worth of navigation choices.

How can I allow horizontal tab navigation (swipe views) with action bar navigation tabs?

How can I allow horizontal tab navigation (swipe views) if I'm using action bar navigation tabs?
Is there anything special I have to do to get this to work with ActionBarSherlock?
The code-generated stuff for a "Tabs+Swipe" activity (from BlankActivity in the new activity wizard in Eclipse) has code for this. Basically, your tabs tie into a ViewPager, calling setCurrentItem() to change the page, rather than running their own FragmentTransaction or otherwise affecting the UI. The ViewPager handles the horizontal swiping, and you populate those pages using some form of PagerAdapter (one is code generated for you). See this very related question and answer for more.
Is there anything special I have to do to get this to work with ActionBarSherlock?
Other than standard stuff for using ActionBarSherlock, nothing out of the ordinary should be required. ViewPager is in the Android Support package, which ActionBarSherlock also needs, so you will have that already in your project.
Note, though, that action bar tabs only sometimes show up as tabs. In some screen sizes and orientations, they are automatically converted into a drop-down list (per "list navigation" with the action bar instead of "tab navigation"). If you want to use tabs all of the time, rather than using action bar tabs with ViewPager, use PagerTabStrip (from the Android Support package) or a suitable indicator from ViewPagerIndicator instead.

Categories

Resources