I started creating my app with min SDK 15 and I used the v4 support library for the fragments and the fragment manager and fragment transaction etc. When I decided to use card animations, I figured I had to switch to using the fragments without the support library. But when I did this, once I press the back button, the whole app closes instead of returning to the previous view. What could be the cause of this?
I fixed the issue by extending only activity instead of the support deprecated ActionBarActivity.
Related
I have an app which supports Android 4.0+ (i.e. android:minSdkVersion="14"). I've created a ListView and when clicking on its item the app moves to an Activity with single Fragment in it. I want to implement swiping between this items (like in Gmail app between conversations), but the only approach I see is using the ViewPager, which is a part of Compatibility library. So maybe there is some way to implement this behavior without using support libraries (which also means changing Activities to FragmentActivities, FragmentManagers to SupportFragmentManagers, android.app.Fragment to Fragment from support library and so on).
Can I avoid this somehow or should I use ViewPager and support library even if minsdkversion="22"?
i don't think using viewpager will cause you any problem because viewpager doesn't require minsdkversion = 22.
I created an application with a navigation drawer navigating following the android documentation tutorial. Now the main parts of my application are Fragment but the problem is I have to use dynamic fragments in one of them.
I saw the nested fragments were supported since android 4.2, but I need to use my app on older version.
What can I do ?
I'm thinking of using a FrameLayout of fixed fragments and to set them visible or gone depending of what I need, but it seems a little ugly...
What do you think ?
Thanks for your answers
Edit :
my question is not clear but what I want to know is :
can I use the navigationdrawer with activities instead of fragments ?
is the solution I'm thinking about realy ugly ?
how can I use the nested fragment system for older version ?
In the end I used the nested fragment system using the Android Support Library (thanks Nobu Games)
Thanks for your comments
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.
I want to show my activities inside of a running activity. I need something like frame in html language that is used for showing other pages inside a page. I know Tabhost has this ability. Which one of other controls has this ability?
Thanks,
Google introduced fragments in Android 3.0 and upper to create a portion of user interface in an Activity. But it is not two Activity, becuase activity <> window. For lower version you can manually load xml layout in your activity.
The Fragment API is really your best choice, it's quite easy to use and you can dynamicly add them to your Activity Layout (take a look to Framgent For All - google Article) by code using the FragmentManager, this feature it's since 3.0 altough Google also released a pretty nice Compatibility Package that you can download out of the SDK Manager and added to your project like this Fragment For All: