Actionbar tabs with multi-pane view in android - android

I am newbie with fragments and actionbar in android.
I want to develop application for tablets which has multiple tabs, each tab has Listview in the leftside and the details of the item on the right side
Here is an example of what i want to do.
I don't know which of this is activity and which is a fragment and how to navigate using this tabs and change the content of the listview and the details.
I want examples to navigate using tabs with multipane layout because I searched about that and I found tabs are using fragments and multipane is composed of two fragments and nested fragments not allowed in android.
And I want to know: What is the difference between activity and fragmentActivity?

Fragment Tutorials
Google "android fragment tutorial" and you'll get a lot of results like this:
http://www.vogella.com/articles/AndroidFragments/article.html
Don't stick with only one though because many of them vary just slightly and if you do two or three then you'll have a better understanding of how fragments work (standalone or multipane).
Fragments with Tabs
A great way to see an example of switching fragments is by creating a new android project in Eclipse using the latest ADT. Create a new Android Application Project and when you're setting the name of the main activity you have an option to set the navigation type. Choose tabs or tabs+swipe. This will generate a clean project for you to see the very basics of how to switch fragments using tabs.
Activity vs FragmentActivity
Essentially, an Activity may contain a layout with no fragments and a FragmentActivity may contain a layout with fragments. This answer has a few more details: Difference between Activity and FragmentActivity

Related

How to handle multiple activities with fragments?

I need to implement an app through fragments.
Based on my requirements,i have a menu panel one side and other side i need to display different ui screens based on menu selection.
My Screen contains heavy ui.That why i design each screen separately.
How should i display screens based on menu selections through fragments.
If any one know the solution,Please help me
Thanks in advance.
If you mean the NavigationDrawer you find the official Tutorial on the Android Developers Website
There is also an example to download, which uses the NavigationDrawer to switch Fragments.
If you want a fixed, self-designed Menu and just want to swap out Fragments (holded by a FrameLayout) check out this Tutorial
Android officially doesn't provide more than one sliding menus (navigation drawers). You can implement SlideMenu or choose one of many such libraries for more than one sliding menus.
Once the menus are implemented, it's just a simple case of fragments and activities. There is no "direct way". Read the documentation and understand how they work. Here are some good links
Fragments - Introduction on developer site
Tutorial on multi-pane development using fragments by Mr. Vogel
Basically what you have to do is, create an Activity extending ActionBarActivity (from support library) or FragmentActivity.
create fragments and replace them in FragmentManager from your main activity.
See this for reference:
Creating a navigation drawer

Navigation with ActionBar Tabs & nested fragments

If you are using an Actionbar with Tabs for navigation, should we be using fragments only?
When I'm looking at the developer site, I only see examples where they are switching Fragments, not Activities. The guidelines tell us to use a ViewPager when using tabs, so you should use Fragments to make that work.
The problem is that these fragments will contain quite a lot. They should have other fragments as well. Nested fragments. These are supported when using the Support Library (or targetting api level 17).
My main concern is how the communication will run between the fragments at the bottom of the hierarchy. Will it all run through that one Activity?
You won't have problems. Just treat your fragments as something independent that will be placed in a container. That fragment can have more fragments and so on.
Some people are developing fragment based applications with a single Activity and sometimes makes sense, however I don't like that approach much.
That said, just use all the fragments you need. If you have complex data to pass between fragments you could use the activity to host it and access it in your fragments.

Actionbarsherlock use activities or fragments

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

Mono for Android, TabHost with abs to swap Views within the same Activity

I'm new to Mono for Android, and I'm trying to port an old application, and I'm having difficulties with TabHost ...
In the tutorials page Xamarin writes:
"You can implement your tab content in one of two ways: use the tabs to swap Views within the same Activity, or use the tabs to change between entirely separate activities.
In this tutorial, you'll create a tabbed UI that uses a separate Activity for each tab."
Someone can help developing something "use the tabs to swap Views within the same Activity"?
Thank you
Now you have tabs on the ActionBar, and your "content" zone will be made of fragments.
Follow this link for further explanation and tutorial on how to add tabs to your app:
http://docs.xamarin.com/Android/Guides/Platform_Features/Introduction_to_Ice_Cream_Sandwich#Action_Bar_Tabs

Fragment Tabs and Fragment Activities

I have created an app using Fragments throughout, as per the guidelines, so that I can show more detailed views on larger screens. However I also want to use tabs for navigation, which as per the guidelines should also be fragments rather than the deprecated TabHost.
Some Googling has shown that you can't / shouldn't nest fragments. My question is what are you meant to do if you want to have tabs, but you also want to support fragments for different size devices? Should I be removing the fragments and making two separate activities for phones and tablets?
Making it more confusing, the design guidelines here, show tabbed navigation and then what looks like a fragment activity. Is this a case of nested fragments or are they separate activities?
There is an API demo a code sample that demonstrates combining a ViewPager and a TabHost to switch Fragments: Support4Demos/src/com/example/android/supportv4/app/FragmentTabsPager
If you don't like TabHost, here is another example of the same code but using ActionBar tabs and ActionBarSherlock: http://code.google.com/p/sherlock-demo/

Categories

Resources