Jacksonkr
Jacksonkr

Reputation: 32247

Android app for all devices

I'm working on an app that is targeted for version 2.3 so that it will run on my sister's phone. However, I can run 4.0 on my phone. I want to add some swipe animations and such but I don't run the animations to run on her phone.

Is this even possible?

Upvotes: 0

Views: 82

Answers (2)

Brent Hronik
Brent Hronik

Reputation: 2427

You can use a ViewPager and FragmentPagerAdapter to provide swipe functionality among various Fragments. All of which are available in the support library.

ViewPager(Note, don't do anything with the ActionBar, as they are not yet in the support library): http://developer.android.com/reference/android/support/v4/view/ViewPager.html

FragmentPagerAdapter(pretty much the example code you will need): http://developer.android.com/reference/android/support/v13/app/FragmentPagerAdapter.html

Fragment: http://developer.android.com/reference/android/support/v4/app/Fragment.html

Upvotes: 0

Booger
Booger

Reputation: 18725

Yes, simply put the API specific code in a if/else block, so it is only called when the system supports it:

Like this:

if (currentapiVersion < android.os.Build.VERSION_CODES.JELLY_BEAN) {
//do things that are only supported on JellyBean
} else {
//do the other stuff
}

Upvotes: 1

Related Questions