为了支持低版本的Android,一般都要使用到Google提供的支持类库,但今天在设置支持类库的时候,总是遇到错误,弄了大半天才搞定,做个记录,以供遇到同样问题的童鞋参考. 首先需要下载支持库,使用SDK Manager即可,位置在<sdk>/extras/android/support/...。下载好后,需要将你需要的类库copy到你当前工程的同一个目录下,一般在workspace下,不然在添加引用类库的时候会得到一个红叉,完整的请参考文档,路径为:docs/tools/support-library/setup.html.我这儿只截取在eclipse下的设置.
Create a library project based on the support library code:
  1. Make sure you have downloaded the Android Support Library using the SDK Manager.
  2. Create a library project and ensure the required JAR files are included in the project's build path:
    1. Select File > Import.
    2. Select Existing Android Code Into Workspace and click Next.
    3. Browse to the SDK installation directory and then to the Support Library folder. For example, if you are adding the appcompat project, browse to <sdk>/extras/android/support/v7/appcompat/.
    4. Click Finish to import the project. For the v7 appcompat project, you should now see a new project titled android-support-v7-appcompat.
    5. In the new library project, expand the libs/ folder, right-click each .jar file and select Build Path > Add to Build Path. For example, when creating the the v7 appcompat project, add both the android-support-v4.jar and android-support-v7-appcompat.jar files to the build path.
    6. Right-click the project and select Build Path > Configure Build Path.
    7. In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on this library project. For example, the appcompat project requires you to export both the android-support-v4.jar and android-support-v7-appcompat.jar files.
    8. Uncheck Android Dependencies.
    9. Click OK to complete the changes.
You now have a library project for your selected Support Library that you can use with one or more application projects. Add the library to your application project:
  1. In the Project Explorer, right-click your project and select Properties.
  2. In the Library pane, click Add.
  3. Select the library project and click OK. For example, the appcompat project should be listed as android-support-v7-appcompat.
  4. In the properties window, click OK.
上个图片吧: 因为我需要使用的是支持库提供的PopupMenu,因为没有改主题结果还遇到一个java.lang.RuntimeException: Binary XML file line #17: You must supply a layout_height attribute.错误,将Actiity的主题改成:android:theme="@style/Theme.AppCompat"就可以正常工作了! 希望能够帮到遇到同样问题的童鞋!

更多相关文章

  1. [置顶] Android艺术开发探索学习 之 测量view的宽高 以及 动态设
  2. Android的设置界面及Preference使用
  3. Android(安卓)动态设置TextView的drawableLeft等属性
  4. 用Basic开发Android的应用.Basic4Android.
  5. Android(安卓)SpannableString 设置文字圆角背景
  6. Android辅助功能
  7. Android开发-UI开发
  8. android中使用代码混淆出现Conversion to Dalvik format failed
  9. android 中几个常用属性的设置

随机推荐

  1. jQuery弹出窗口不能打开。
  2. 将php jsonencode数组结果显示为ajax成功
  3. 【JavaScript】jQuery+ajax传递json数组(
  4. 如何使用XMLHttpRequest向服务器发送数组
  5. jquery validate和jquery form 插件组合
  6. 使用jquery ajax代替iframe
  7. 在没有重新设置源选项的情况下,使用x-edit
  8. 函数的作用是:显示内联块。如何?
  9. 前台jquery+ajax向后台请求数据,后台返回j
  10. 使用js和ajax从django服务器检索数据