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
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'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
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
I have an existing app that is using a Dashboard style pattern where there's a main menu, and clicking icons on the main menu drive start different activities... In order to navigate to a different function, you need to go back to the Dashboard menu and select another icon.
I want to change my application to a tabbed format similar to the one below with Icons:
What type of View is being used below? Is this a FragmentActivity? Also, what is the best approach to go about conversion? I have a bunch of layouts with listviews in linear/relative layouts... Will I be able to reuse any existing code? I want also to be able to use the solution with Android 2.1 and up if possible.
Thanks!
In the image you provided, it looks to be a TabHost that is used (which can be within a normal Activity or a Fragment Activity) and will be available for Android 2.1 and beyond when using the Android Support library. Based upon your description, you most likely have an Activity per each of your items that you will probably want to convert into a different Fragment. This may take a little time, but a Fragment is very similar to a normal activity in many ways, so once you start getting used to it, converting over the old Activities should be a breeze.
If you plan on using these tabs and you follow the Android design UI guidelines, you may want to use the TabHost in conjunction with a ViewPager. There is a great tutorial for this online that also allows for backward compatibility (down to at least 2.1) found here: http://thepseudocoder.wordpress.com/2011/10/13/android-tabs-viewpager-swipe-able-tabs-ftw/
Support library for fragments/viewpager: http://developer.android.com/tools/extras/support-library.html
More info about a TabHost and using Tabs with fragments can be found here:
http://developer.android.com/reference/android/widget/TabHost.html
http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/
You can use TabLayout and a TabActivity to achieve layout in picture. Bad news is these are deprecated as of Android 3.0. Google advises to use fragments instead of these.
Can I implement a tab host which will remain in overall application and works through out the application .
and
Also can i implement the tab host on the top and on the bottom of the same activity.
Any tutorial any help please....
Thanks
This is possible if you use Activity Group. But still it is deprecated and hence you cannot use it for newer versions of android. But still, you can go through what it is and try to implement it.
ActivityGroup Example
http://blog.henriklarsentoft.com/2010/07/android-tabactivity-nested-activities/
http://gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity
So now since Activity Groups are deprecated what is the alternate strategy we can make use of? Here is the solution for this problem.
Go for fragments or Views.
I have pasted the comment which I recieved from Commonsware regarding the ActivityGroup.
You never needed ActivityGroup to use tabs. You can put views in tabs, for example (github.com/commonsguy/cw-android/tree/master/Fancy/Tab). Going forward, tabs are in the action bar on Honeycomb, typically using fragments. You can achieve the same functionality on previous versions of Android using ActionBarSherlock.