Sandy
Sandy

Reputation: 1005

Issue when removing the supportV4 library

My app minimum version is 10 and till now i am using the support library for fragments

Now i want to add the flip animation for few fragment transition So as per the android guide we need to use the animator for that and it has support from the api level 11 which is no issue for me.

but also need to use the getFragmentManager instead getSupportFragmentManager

So i removed the support library changed my minimum version 10 to 11 errors are coming

because in my app i have FragmentTabhost and getChildFragmentManager(). FragmentTabHost only available on support library and to set FragmentManager using the getChildFragmentManager it wont allow me to do that because it requires api level 17

any help appreciated. Let me know if you need more details

Thanks in advance.

Upvotes: 9

Views: 217

Answers (4)

venkatesh venkey
venkatesh venkey

Reputation: 391

use android.support.v4.fragment instead of android.app Fragment in your project

and you can use following snippet for animation while adding/replacing fragment

 getSupportFragmentManager().beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.replace(R.id.fragment, new FragmenntTwo())
.commit();

where FragemntTwo() is the fragment you are inflating.Here you can use your custome animation as well by replacing setTransition(..) with setCustomAnimations(..)

Upvotes: 5

Josh.M
Josh.M

Reputation: 103

For FragmentTabhost ,I used to build a program with app.Fragment,but suddenly my PM told me he want to use ViewPager +Fragment. What i did was copy the FragmentPagerAdapter.class from v4.jar and replace all these v4.Fragment with app.Fragment.I think this may help you. And for getChildFragmentManager(), @SuppressLint("NewApi") may help you.

Upvotes: 2

The Original Android
The Original Android

Reputation: 6215

I think coding Animation for API level 10 and below is challenging, and rather obsolete. I can give one suggestion, read web page @ NineOldAndroids from the active developer Jake Wharton. It supports Android 1.0 and up, though deprecated with new Android libraries. So one lesson is that it would be easier for you to create a new project, basically start over instead of converting code.

Even if you do use existing animation like ValueAnimator, the API level is 11 and up. You're hitting that boundary between level 10 and 11 for animation.

Good luck and keep us posted.

Upvotes: 4

null pointer
null pointer

Reputation: 5914

Custom animation works with Support Fragment manager too. you will be able to use the support fragment manager and still animate it.

Upvotes: 3

Related Questions