Creating Navigation Tabs in Android - android

I'm new to Android (and Java to some extent).
My question is how can I create a tabbed action bar for navigation in an Android Application?
The possibilities and variances are mind boggling and i cant tell what is useful or not.
On the Android developer site it says you can use navigation tabs with fragments but all i want the navigation tabs to do is start activities so fragments seems overcomplicated and unnecessary.
All I want is a nice tabbed navigation bar with three options. I also have one option in the action bar for a quick action. Some sites are suggesting action bar sherlock but this is throwing up errors that i cant seem to fix.
Surely i dont have to download a whole separate library just to make a tabbed action bar that starts activities when each is touched.
(sorry im really new to this and Android is totally impenetrable at the moment)

Take a look at the action bar api:
http://developer.android.com/guide/topics/ui/actionbar.html
Also, realize that you don't need to download "extra" libraries.

I am an Android developer and when I first started, figuring out all of the ways to build Android apps was overwhelming. Navigational tabs were my worst issue. You can read all about tabs here. If you would like some code examples there are repositories on Github like this one.
Hope this helps,
Andrew

Related

Android material tabs w/ appcompat

I want to setup a 'tabbed' application. Looking through all the tutorials including the google docs here:
http://developer.android.com/training/implementing-navigation/lateral.html
However as I start to go through the docs I get all kinds of deprecated warnings:
actionBar.setSelectedNavigationItem(position);
I would really like to start off right and use any new non deprecated methods. Most examples of tab applications are years old. What am I missing? Am I searching for the wrong thing? Can someone point me in the right direction for developing a tabbed application.
What am I missing?
Action bar tabs were deprecated in Android 5.0, last fall.
Can someone point me in the right direction for developing a tabbed application.
Use TabLayout, though this is a very new addition to the Android Support libraries.
Or, use ViewPager with your favorite tabbed indicator, of which there are many.
Or, use FragmentTabHost.

ActionBarSherlock is the correct choice?

I'm looking to make a layout where there are tabs at the top. The tabs would be:
Friends, Requests and Search. I would like the Friends and Requests to be buttons as they need to be read where as I would like the Search to be the generic magnify glass. I have had this working with a fairly generic setup however the SearchView is squished and can't be read.
Would ActionBarSherlock allow me to accomplish this?
Is ActionBarSherlock capable of creating such action bars below the main actionbar at the top of the screen?
If it isn't what would be the best way to accomplish this kind of view?
Cheers,
Jake
The Android SDK now offers a native solution for the ActionBar pattern. It's available through the v7 appcompat library. So, there's no need to integrate Action Bar Sherlock on you app.
All the info you need and related links can be found at Developer Android Site.
The purpose of ActionBarSherlock is to bring the Action Bar to older (pre-Honeycomb) devices. If that isn't a requirement, you don't need ABS and I recommend not using it. Here's some documentation on using the latest APIs to do what you need:
Tabs
Search
I have used ABS before and it is completely OK to go with it. In case you don't have any constraint to use only ABS it is always better to go with Android's action bar

Android Tab Bar Controller (Fragment or Action Bar or TabHost)

I've been slowly porting my iOS App to Android so I can take my time and make sure that it functions correctly and I'm now at the part where I need to create a TabBarController like environment. I've been searching for days and have come across numerous examples but with each example there's a problem.
First, most examples refer to using a TabActivity, which when I just checked is deprecated and can't be used. The one's that don't use TabActivity either use Fragments (sometimes with an Action Bar) or a Tab Host. It looks like Fragments is the way to go, but then how to you support older devices (from the Android website over 50% of there users are still on API 10).
Basically what I need to set up is a Tabbed environment that will let each tab load a new Activity, and then each of those Activities will have their own navigation based hierarchy as well so I'm trying to see what is the best option to pursue and if anyone has seen some examples that can help.
I've found 4 tutorials so far that have fragments and different activities for each Tab, so I'm going to look into those now but just wanted to see if any other developers that have already come across and issue like this did to work with the compatibility issues with older devices.
You can use Fragments all the way down to API 4 using the Support Library. I'd use a single Activity with multiple Fragments in ActionBar tabs, though you might need to do it with TabHost to support lower APIs.

Correct Way To Implement A Tabbed Bar

I have been browsing the web for a while now and looking at different examples of how to implement a tab bar.
The problem I am having is deciding the correct approach to creating this feature. The option that seems most used is to have one main activity called MainActivity or something and using fragments as the tabs. This is all well and good and I have created an application like this fine.
The problem I am having is I am in two minds as to whether this is the right way to go about it as coming from an iOS development background it just doesn't seem right due to these tabs having different functions.
Any pointers would be great.
EDIT I have also looked into ActionBarSherlock but couldn't get to use it in a project as it kept coming up with errors and I couldn't find a thread that sorted the problems I was having out.
Disco
You should be using fragments, yes. There is an example of how to do it here: http://developer.android.com/guide/topics/ui/actionbar.html#Tabs
This "only" works with Tabs that are part of your Actionbar, though. Shouldn't be too much of a problem, because they usually should be part of your Actionbar. You can also manually move the tabs if you're not content with their location, or roll your own buttons that look like tabs.
Keep in mind that tabs in Android aren't quite the same beast as the tab bar is in iOS. They look similar and behave similar, but there are subtle conceptual differences in how they are supposed to be used. Don't use them for your basic app navigation, but rather for switching between similar "things".
If you want to employ this on device pre-3.0 though, you will have to use ActionBarSherlock. It does work fine and we're using it in several projects, so if you're having problems integrating it I suggest creating a new question for that, I'll be happy to help.

android pop up menus

I cannot find either one of these two views in the source, but have seen them both in many apps. Can anyone please tell me what they are called?
Thanks
The second one is an options menu from the action bar. I think it is implemented as a ListPopupWindow.
The first one is not part of the Android SDK, though there are various implementations floating around. Here is an example of one designed for use with Google Maps, for example. Here is one designed for the "quick actions" pattern.
I'm going to assume that they're custom made ones, so you won't find them in the standard Android libraries.
The second one I think is just the way that the default menu looks in ICS (and honeycomb for that matter). If you build for 4.0 and include the code for an options menu I think you'll get that UI by default. If you are looking to customize it check out this page http://developer.android.com/guide/topics/ui/actionbar.html and pay close attention to the "Adding drop down navigation" section.
The first one is not a part of the android UI, that is something specific to the facebook app.

Categories

Resources