Handling tabs, actionbar, activities and fragments - android

I am facing problem in designing following scenario :
Showing 3 tabs for contact-lists (all, friends and family)
All tabs would contain contact-list as per the groups
Any contact could be selected and viewed but should be in the same tab (either all,family or frnds)
In short, tabs should be available globally.
Here, I decided to use ActionBar and to change the view by using fragments to be called from onTabSelected() of TabListener; in which I was confused as I have to keep only single activity but multiple fragments.
'Keeping single activity' is this a standard / valid approach ? Please suggest.
Thanks in advance.

You should have a single Activity and have a container(could be an empty LinearLayout) in which fragments are replaced depending on the tab selected.

I know this is late, but I used a tabhost with fragments to do something similar. Here's a nice tutorial.
http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/

Related

How to use activities in a swipe views with tabs

In one app, I would like to use three activities with a swipe view with three tabs; each tab triggering an activity
(In the doc I have read about ViewPager and fragments, but it is for a different purpose); if it is possible how can i do that ?
if it is not, must i break my app in three app ?
Thank you.
Having activities in tabs has been deprecated as a technique for over five years.
Whether you use fragments or views for your ViewPager pages is up to you.
if it is not, must i break my app in three app ?
No, you can have multiple fragments or multiple views within one app.
Make one activity with three tabs and one ViewPager. Each tab then change fragments in the ViewPager

How to make tabs/sub-fragments inside a tab/fragment in Android

I have implemented an ActionBar with 3 tabs in an android app. I also used ViewPager to switch between different tabs. Every tab is defined in a fragment.
The last tab is called "Setting". I have two different settings. One is "Simple" setting, and the other one is "Advanced" setting. How can I implement these two different settings in the "Setting" tab. Should I make kind of sub-fragments or two new tabs inside the main tab which is "Setting" tab? Can I also for example create two buttons at the top, and switch between them? Or any better idea? Which solution is easier and more efficient. I'm a newbie in Android.
I want to make something like this:
Hope this help
Take SettingFragment as Host fragment
Place both buttons on top and ViewPager below buttons
Take SimpleFragment and AdvanceFragment as items in ViewPager

Android Tabs, Detail View on tablet

I'm currently designing the following 2 pane layout and I'm wondering on how to implement it.
Link to Wireframe
So far, I made a two pane activity. On the left is a custom ListView fragment. On the right is a detailpane. The detail pane is what I'm having trouble implementing. I don't know how to create a tab view that doesn't use the actionbar and I'm curious if the best way is to use a ton of fragments for the detailpane or just add change the data dynaically.
[The reason I don't want to use the action bar is that I'm using it for my Help/Refill buttons]
So what tools/tutorials/advice can anyone recommend in implementing this?
Additional information:
Categories or the Tabs will be based on a JSON array.
The listview inside the tabs will be filled with items from a JSON array.
Let me know if you need any more information.
I am currently using a FragmentTabHost and it's just perfect!
You can have your ListFragment and a simple Fragment with your details.
And use your FragmentActivity to communicate with them.
You just need to override the onAttach method of your activity which is called when a Fragment is displayed.

Add/Remove Tab and its content from tabhost

I have nine tabs(say 0 to 8), displaying only five tabs on screen.
The five tabs will be 0 to 3 of those nine tabs and fifth tab will be MORE Tab.
MORE tab will show Activity with GridView showing Image+Title of remaining nine tabs(say 4 to 8).
Now on click of any item(Image+Title) in GridView will replace the MORE Tab Image+Title and its content/activity with its respective activity.
I am able to replace the tab indicators(Image+Title) but struggling on replace its respective content/activity.
As on other similar thread they had suggested to use clearAllTabs and add/recreate require tabs again. But i feel clearing all tabs just to replace one tab is heavy.
I am using the TabActivity with Intents. As i know TabActivity is deprecated by its old app initially it had only 5 tabs but now requirement is to add few more tabs.
Need your help to implement this. If it not possible with TabActivity, then switching to fragment tabs does it help me?
I trying to implemtent this Image
I would recommend fragments for sure. I've used TabHost in the past and it was very problematic.
You can simply have Button at the top that control the visibility of the fragment below. With this way, you'll even be able to add transitions.
This link give a little more information on that topic. Separate Back Stack for each tab in Android using Fragments

Android - Change content view of TabHost

I try to create a android application with tabHost and I would like to avoid to set intent(activity) for the content of these tabs.
I succeed to create my tabMenu but I would like to change the view of one tab.
How I can do that ?
For example I have one view for Tab1 and two views for Tab2 (when the user click on the button of Tab2_view1 then the content change to Tab2_view2 and the indicator doesn't change (stay on "tab2")).
I hope it is possible but I don't find the way to do that without using different activities for each tabs.
Maybe my conception is bad (I am novice in Android dev.)...
Thank you very much for your help,
Fred
Android has ActivityGroup for the same purpose that you are looking for. By using ActivityGroup you can show multiple views in a single Tab by maintaining the stack of the Views.
ActivityGroup Example 1
ActivityGroup Example 2
Fragment - Answer to me by hackbod

Categories

Resources