Using the Support Library
来源:互联网 发布:ovd后缀名是什么软件 编辑:程序博客网 时间:2024/06/08 03:36
Using the Support Library
5、使用Support Library(支持库)Using the Support Library
负责人:River
完成时间:7月18日
原文链接:http://developer.android.com/training/basics/fragments/support-lib.html
Android Support Library(支持库)提供了包含一个API库的JAR文件,当你的应用运行在Android早期版本时,Support Library(支持库)允许你的应用使用最近版本的Android API。例如:Support Library提供了Fragment版本的API,这样你就可以在Android1.6(API level 4)或者更高的版本上使用Fragment API了。
这节课将为你演示如何在你的应用中设置Support Library,并且使用Fragment构建一个动态的应用UI。
设置你项目的支持库 - Set Up Your Project With the Support Library
设置你的项目:
1使用SDK Manager下载Android Support包
2在你项目的顶层目录下创建libs目录
3找到你想要引入库的JAR文件,然后将它复制到libs目录
例如:支持API Level 4的库就位于<sdk>/extras/android/support/v4/android-support-v4.jar.
译者注:这个<sdk>代表着你安装android sdk的目录,比如本人的完全目录为:E:\android-sdk-windows\extras\android\support\v4\android-support-v4.jar
4修改你的manifest文件,设置最低级别为API level 4,目标API level为最新版本:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" />
图1: Android SDK Manager,其中Android Support package已选中。
导入支持库API - Import the Support Library APIs
支持库包含了一系列的API,这些API或许在最近的Android版本中增加了,或许在platform(平台)中根本不存在,而仅仅当你开发特定的应用功能时提供了附加的支持。
你可以在android.support.v4.*这个平台支持库中找到所有的API参考文档。
警告:请确保你不是恰好在一个老系统版本中使用新的API,请确认你引入的Fragment类以及相关的API都来自android.support.v4.app包
import android.support.v4.app.Fragment;import android.support.v4.app.FragmentManager;...
当使用Support Library创建有关fragment的Activity时,你必须继承FragmentActivity类,而不是传统的Activity类,你将会在下一节课中学习到一些简单的关于fragment以及Activity的代码。
- Using the Support Library
- Using the Support Library
- Using the iPod Library
- Using the WixUI dialog library
- Using the OData Ajax library
- Finding Memory Leaks Using the CRT Library
- Finding Memory Leaks Using the CRT Library
- Network socket programming using the NetLib library
- Support Library
- Support Library
- This template depends on the Android Support library
- Install the new caffe with support cuDNN library
- Material Design with the Android Design Support Library
- android support Library—-Percent Support Library
- Dojo: Using the Dojo JavaScript Library to Build Ajax Applications
- A Brief Introduction to the log4net logging library, using C#
- load the C runtime library without using a manifest
- the creating,installing and using of shared library
- Exchange Server 2013架构设计示例一
- 多线程编程技术(第十四课)
- Exchange Server 2013架构设计示例二
- 异步编程技术(第十五课)
- Eclipse+Maven配置
- Using the Support Library
- Creating a Fragment
- ADO.NET概述(第十六课)
- Building a Flexible UI
- 通过交换虚函数表指针查看虚函数的实现方式
- 使用LINQ ToSql(第十七课)
- IOS之计时器
- 实体数据模型(第十八课)
- STM32F051R8芯片介绍