Android, Is It Possible To Put Two Different Activities In Screen Of Tablets Using Fragment?
Solution 1:
Yups, you can make as many activity on your screen as you want using Fragments.
Fragments was developed by google as the screen size of tablet is large and we can accommodate more functionality in one screen. All work is done by FragmentManager. You can make an XML layout with as many fragment view you want in any pattern. Then associate all the view to an individual activity. Activity can communicate between each other also. More you can find in following examples.
- http://www.vogella.com/articles/Android/article.html#fragments_tutorial
- http://android-developers.blogspot.in/2011/02/android-30-fragments-api.html
- http://mobile.tutsplus.com/tutorials/android/android-sdk_fragments/
EDIT
What you need to do is get the width and height using following function.
@OverridepublicvoidonCreate(Bundle icicle) {
WindowManagerw= getWindowManager();
Displayd= w.getDefaultDisplay();
intwidth= d.getWidth();
intheight= d.getHeight();
Make different layout for different dimension of screen. Now keep if else loop to decide which layout to be set using setContentView(R.id.layoutfor10inchtable)
etc.
For configuration change, make one boolean variable say permitConfigurationChange and when you are setting the view, you can also set this variable to true or false in if else loop.
The override onConfigurationChange method. In if check if (permitConfigurationChange == false) return;
Design part for layout, you need to see the tutorials, they will provide you all the details.
Solution 2:
1、You can use fragment instead of Activity. (Not really instead)..
Solution 3:
At first Fragments are not used to display Title/description type pages only. Instead, Fragments are activity component which can work independenty, irrespective of other components on the activity. Fragments also can maintain their own backstack. So, Its always possible to have four fragments on one screen/activity. What you need to do, create four classes, which extends Fragment not Activity, and Add these fragments to MainActivity.
Post a Comment for "Android, Is It Possible To Put Two Different Activities In Screen Of Tablets Using Fragment?"