博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android.support library找不到的解决方法
阅读量:5874 次
发布时间:2019-06-19

本文共 4764 字,大约阅读时间需要 15 分钟。

Downloading the Support Package


The Support Package is provided as a downloadable package from the Android SDK Manager. To install:

  1. Launch the Android SDK Manager.

    From Eclipse, you can select Window > Android SDK Manager. Or, launch SDK Manager.exe from the <sdk>/ directory (on Windows only) or android from the <sdk>/tools/ directory.

  2. Expand the Android Repository, check Android Support package and click Install selected.
  3. Proceed to install the package.

When done, all files (including source code, samples, and the .jar files) are saved into the<sdk>/extras/android/support/ directory. This directory contains each of the different support libraries, such as the library for API level 4 and up and the library for API level 13 and up, each named with the respective version (such as v4/).

Setting Up a Project to Use a Library


To add one of the libraries to your Android project:

  1. In your Android project, create a directory named libs at the root of your project (next to src/res/, etc.)
  2. Locate the JAR file for the library you want to use and copy it into the 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.

  3. Add the JAR to your project build path.

    In Eclipse, right-click the JAR file in the Package Explorer, select Build Path > Add to Build Path.

Your application is now ready to use the library APIs. All the provided APIs are available in the android.supportpackage (for example, android.support.v4).

Tip: To see the library APIs in action, take a look at the sample apps in<sdk>/extras/android/support/<version>/samples/.

Warning: Be certain that you not confuse the standard android packages with those in android.support library. Some code completion tools might get this wrong, especially if you're building against recent versions of the platform. To be safe, keep your build target set to the same version as you have defined for your  and double check the import statements for classes that also exist in the support library, such as SimpleCursorAdapter.

Using the v4 Library APIs


The support library for v4 provides access to several classes introduced with Android 3.0 and beyond, plus some updated version of existing classes, and even some APIs that currently don't exist in the Android platform. Some of the most useful and notable classes that have counterparts in the v4 support library are:

For each of the classes above (and others not listed), the APIs work almost exactly the same as the counterparts in the latest Android platform. Thus, you can usually refer to the online documentation for information about the supported APIs. There are some differences, however. Most notably:

  • When creating an activity to use fragments, you must declare your activity to extend the  class (instead of the traditional  class).
  • To manage your fragments and loaders, you must use the methods and (instead of the  and  methods).
  • The  is not supported by the library. However, when creating your , you can declare which items should be added to the Action Bar when it's available (on Android 3.0 or later). You can do so with the method, for example:
    publicboolean onCreateOptionsMenu(Menu menu){
        MenuInflater inflater = getMenuInflater();     inflater.inflate(R.menu.options, menu);     MenuCompat.setShowAsAction(menu.findItem(R.id.action_search),1);     returntrue; }

    Also see the  sample for a demonstration of how to use  on Android 3.0+ and also support action bar functionality on older versions.

Tip: To enable the Holographic theme on devices running Android 3.0 or higher, declare in your manifest file that your application targets API level 11, for example:

This way, your application automatically receives the Holographic theme and the Action Bar for each activity when running on Android 3.0 and higher.

For more information about how you can optimize your application for the latest Android-powered devices, read.

Reference Docs


The reference documentation for the Support Packages is included as part of the Android online developer documentation:

Samples


If you want to see some code that uses the support libraries, samples are included with the Support Package, inside each support library directory, for example; <sdk>/extras/android/support/v4/samples/. You can also view these samples as part of the Android online developer documentation:

Additionally, the  is a complete application that uses the v4 support library to provide a single APK for both handsets and tablets and also demonstrates some of Android's best practices in Android UI design.

欢迎加群互相学习,共同进步。QQ群:iOS: 58099570 | Android: 330987132 | Go:217696290 | Python:336880185 | 做人要厚道,转载请注明出处!http://www.cnblogs.com/sunshine-anycall/archive/2013/02/21/2919882.html
你可能感兴趣的文章
f1 score 代码_特征选择总结之 过滤式特征选择(附代码)——单变量过滤式特征选择方法总结...
查看>>
activty在哪个栈里面_Javascript之调用栈解析
查看>>
天兔(Lepus)监控邮件推送安装配置
查看>>
库存分配
查看>>
Kubernetes 1.9集群使用traefik发布服务
查看>>
如何在C++中增加给JavaScript调用的API
查看>>
大道至减
查看>>
通过Job,Trigger,Scheduler看Quartz2.x作业调度框架
查看>>
VMware上海谈新云基础架构管理平台价值
查看>>
“二子乘舟”的故事很难讲
查看>>
Global Industry Analysts称全球MSS市场在2017年达到112亿美元
查看>>
XCode编译运行出错解决思路,以及再次推荐AppCode
查看>>
京东和天猫的差异究竟在哪里?
查看>>
恐慌:微商造就了“伪创业”迷局
查看>>
学习:Intents和Intent Filters(实例部分)
查看>>
10个让人眼花缭乱的HTML5和JavaScript效果
查看>>
C语言易混淆关键词详解-const, static, extern, typedef, 声明
查看>>
Redhat Linux从入门到略懂
查看>>
int ,long , long long类型的范围
查看>>
为VM增加磁盘空间
查看>>