How do you ensure resources (e.g. styles) of a sup

2019-02-20 12:14发布

I am trying to implement the actionbarcompat support library project in my android application and I have followed the guidelines here from the android website on how to implement these but the resources of the support library still are not available to my project. Note: I am able to use methods defined from the compiled classes of the library project, I just don't know how to reference from the styles. I am using eclipse IDE. Anybody with an idea how or what I am doing wrong please assist me.

2条回答
Bombasti
2楼-- · 2019-02-20 12:46

I happen to have found my own mistake! Most certainly I know a few others might go the same path.

These are the steps in adding a support library with resources.

  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 /extras/android/support/v7/appcompat/.
  4. Click Finish to import the 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 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. The appcompat project requires you to export both the android-support-v4.jar and android-support-v7-appcompat.jar files. Uncheck Android Dependencies. 8.Click OK to complete the changes.

Now You add the library project to your application:

  1. In the Project Explorer, right-click your project and select Properties.

  2. In the Library pane, click Add.

    • here is where I went wrong. Check if you've done it the right way too (As shown)

Library Pane

  1. Select the library project and click OK. The appcompat project should be listed as android-support-v7-appcompat.
  2. In the properties window, click OK.
查看更多
Explosion°爆炸
3楼-- · 2019-02-20 12:51

Look at the "Adding libraries with resources" section of this document

http://developer.android.com/tools/support-library/setup.html

Basically, you import the resources in a library project called "android-support-v7-appcompat" that you reference in your app project.

查看更多
登录 后发表回答