How to use snippet in Android 2.2?

I have an application that supports android 2.2 library. In this application I want to use a fragment, someone will offer me, if possible, how to do it.

thanks

+6
source share
4 answers

Yes, you need to use the support library. It is important to know that you can use the support library on a honeycomb and ice cream sandwich. Thus, you can use the same assembly on all platforms. You need to use SDK 4.0 as the target with minsdk 2.2. Another problem is the actions with the settings. For Honeycomb +, you can use PreferenceFragment, which are not yet supported by the support library. If you use the new onBuildHeaders PreferenceActivity method and the header tag in the settings.xml file, you need to place this XML in a separate folder, for example, xml-v12, to indicate that it is used only with API-12 +.

For settings, see: http://developer.android.com/reference/android/preference/PreferenceActivity.html there is a good example onBuildHeaders

For the support library: http://developer.android.com/sdk/compatibility-library.html

+6
source

I think that to include the fragment in Android 2.2 you need to add android-support-v4.jar to your project.

+5
source

Right-click the Android project for which you want to add fragment support.

  • Build Path β†’ Configure Build Path
  • Libraries tab
  • Add External JARs
  • Add android-support-v4.jar (should be in the boot android folder under extras / android / support / v4

Also remember to use getSupportFragmentManager instead of getFragmentManager() .

+4
source

You can use the support package as well as the v4 compatibility library for this.

+3
source

Source: https://habr.com/ru/post/903972/


All Articles