How to use this library in Android?

2020-08-01 05:40发布

问题:

I want to make some ActionBar for my application using this library: https://github.com/johannilsson/android-actionbar but I don't know how to import it in my android project. There is no jar file. How can I do?

Flo

回答1:

First, make sure you're using the latest version of the Android SDK, things have improved dramatically within the last few months.

  1. Install the android-actionbar source code, either downloading it and unpacking it, or (preferably) using git to clone the repository on your system.

    (I strongly recommend using the mimic-native-api branch as it is the most up to date.)

  2. Import the android-actionbar project into Eclipse. Note that the library's .project file is located in android-actionbar/actionbar. There is a small sample project in android-actionbar/actionbarexample as well.

    The project's library setting should already be set, but you can confirm this by right-clicking on the android-actionbar project in Eclipse, choosing Properties, and confirming that "Is Library" is enabled in the Android settings category.

  3. In Eclipse, right-click on the project that you want to use the action bar library in, and choose Properties. Select the "Android" category in the list on the left. In the "Library" settings on the right, click the "Add..." button and select the android-actionbar library project.


Tip: I've found Eclipse can get a bit squirrely when you edit library code, if you run into errors that don't want to go away, use Project > Clean... to remove the R.java files, etc. ...then refresh your package explorer and rebuild.



回答2:

You'll want to look at http://developer.android.com/guide/developing/projects/projects-eclipse.html#SettingUpLibraryProject and http://developer.android.com/guide/developing/projects/projects-eclipse.html#ReferencingLibraryProject. The first link explains how to create a Library project: you probably just need to take the github zip file, expand it and then add it to Eclipse. You can then import it into your own project in Eclipse.



回答3:

Just copy the source into your project folder and add each file as a new class