I am trying to add tab bar to my existing app. I have divided all my activities into 2 groups, each group of activities has the navigation controls.
I want to place these activities under corresponding group-1, group-2 tabs.
what is the best way of doing this.
Thanks,
Venkat Papana
Knowing nothing particular about your app its hard to say exactly how to go about doing it, but it seems like you want to implement a Tab Layout and can use the following example as a guide: http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
Related
I have an Android app with two classes:
-MainActivity
-SecondActivity
I have also two layouts for these classes (they are pretty similar).
I want to switch between these activities by 'shifting' to the right or to the left.
All materials I find are about switching by button.
Anyone would recommend using Fragments and ViewPager instead of Activity since you want sliding action and make use of the Android TabLayout.
Here is a tutorial that you can draw a basic idea from.
I want to make something like this in my android app
With 2 or 3 activities or more. I don't want to use visible tabs with names. I just want when i slide through a new activity with its own layout appear, a totally different screen. I've read about viewpager and pageradapter, but i' m a little confused. What do you think is the best way to do it?
This is what you need, just follow this tutorial http://www.androidhive.info/2015/09/android-material-design-working-with-tabs/
You dont even need multiples activities.
You can actually create a swiping activity in android studio.
Goto:
File -> New -> Activity -> Tabbed Activity and choose Navigation Style to be Swipe Views.
Android Studio will do the rest. Then you can change the fragments according to your need.
EDIT:
This is a nice example that demonstrate using Activity with ViewPager.
Android PagerView between Activities
I've been working on a school project in a course for Mobile prototype for a couple of weeks when our mentor said we should change our way of navigate in the app.
Before the app started with a simple menu where the user could chose which feature to open, which could be different activities, listactivities, mapactivities, activities with custom views, ect.
We then found the ActionBarSherlock library which could help us make a nice tab bar. But should we then change our activities to be fragments (supportfragments runs 2.3.3) or can we keep it as (normal) activities? if so how to best show this under each tab.
Actionbarsherlock have been implemented successfully in our apps start activity and now we "only" need to make the navigation to the existing the activities or change them to fragments.
Do tell if this isn't clear what have described or you need any further information.
If you wish you can only use Activities with ActionBarSherlock
It all depends on what your want to achieve and the use of fragment might help you making a cleaner app.
Actionbarsherlock sample:
1° tab bar with fragment & viewpager
2° tab bar with fragment
If you have seen the skype android app, then you may have noticed that when skype moves from one activity to another, the top bar remains in place while the rest of the page slides out and the new activity comes in.
So how are they doing it? I want to do something like that.
Fragments can do what you wan't, and a lot more
In skype.. They are using Tab Activity...
Refer : http://developer.android.com/reference/android/app/TabActivity.html
Android TabHost Tutorial
Also if you want to use a single title through out the applciation :
You can define a title_layout.xml... & include it in the top of all your layouts like
<include layout="#layout/title_header"/>
You need to create a custom view which will act as your Tab Bar.
After creating your custom tab bar use it in whatever activity as you want.
Check this for more info on custom views.
http://developer.android.com/guide/topics/ui/custom-components.html
Hallo,
Any idea where I can find a simple tabs example?
The Android Developers Hello Views Tab Layout example only details how to use separate Activities for each Tab.
I would like to use tabs to extend a screen of settings without scrolling, i.e. there are too many options for a single screen, so I'd like to split them over two tabs, but still handle them in the same Activity.
Each tab can refer to a separate layout file if that is how it needs to be done,
TIA,
-Frink
if your tabs don't need to be dynamic you can just load the views in the xml file. Just like in this example http://developer.android.com/guide/tutorials/views/hello-tabwidget.html
In your tabhost instead of passing an intent you can pass a viewID