本文共 1842 字,大约阅读时间需要 6 分钟。
The Android provides a JAR file with an API library that allow you to use some of the more recent Android APIs in your app while running on earlier versions of Android. For instance, the Support Library provides a version of the APIs that you can use on Android 1.6 (API level 4) and higher.
This lesson shows how to set up your app to use the Support Library in order to use fragments to build a dynamic app UI.
To set up your project:
libs
directory at the top level of your Android project. libs/
directory. For example, the library that supports API level 4 and up is located at <sdk>/extras/android/support/v4/android-support-v4.jar
.
4
and the target API level to the latest release: The Support Library includes a variety of APIs that were either added in recent versions of Android or don't exist in the platform at all and merely provide additional support to you when developing specific application features.
You can find all the API reference documentation for the Support Library in the platform docs at .
Warning: To be sure that you don't accidentally use new APIs on an older system version, be certain that you import the class and related APIs from the
package:
import android.support.v4.app.Fragment;import android.support.v4.app.FragmentManager;...
When creating an activity that hosts fragments while using the Support Library, you must also extend the class instead of the traditional
class. You'll see sample code for the fragment and activity in the next lesson.
转载地址:http://fxgdi.baihongyu.com/