-1

I am very new at implementing custom libraries from github.com

Here is the link I tried to follow:

https://github.com/makovkastar/FloatingActionButton

It seems easy to implement this floating action button, but I need someone to teach me how to follow this instruction.

I get stuck here:

3) Attach the FAB to AbsListView, RecyclerView or ScrollView :

ListView listView = (ListView) findViewById(android.R.id.list);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.attachToListView(listView);

because I don't have FloatingActionButton.java in my project.

Do I have to download all these files :

https://github.com/makovkastar/FloatingActionButton/tree/master/library/src/main/java/com/melnykov/fab

and put all of them inside my package?

I just need some beginner-level guidelines..

Joon. P
  • 2,238
  • 7
  • 26
  • 53
  • 4
    do you have [google](https://www.google.pt/search?q=how%20to%20include%20library%20in%20android&ie=utf-8&oe=utf-8&client=ubuntu&channel=fs&gfe_rd=cr&ei=v5JIVZquG4Ss8we0loGoDA&gws_rd=ssl) in your country ? – Pedro Lobito May 05 '15 at 09:52
  • Do you have this declared at the top of your main activity: import com.melnykov.fab.FloatingActionButton; ? Also, are you getting any errors? – Steve C. May 05 '15 at 09:56
  • Wow, how surprising, I found a [duplicate question](http://stackoverflow.com/questions/18555135/the-best-way-to-integrate-third-party-library-in-android-studio) by typing "third party library android studio" in Google Search. /sarcasm – 2Dee May 05 '15 at 10:10

2 Answers2

3

When you use Android Studio, you generally use gradle build system, and gradle dependencies.

In your project, you have you're root project build.gradle which is usualy tiny (~20 lines) and stay tiny. the second build.gradle is you're application gradle, the application you launch on you're device.

This is the hierarchy :

/
    build.gradle (project gradle)
    app/
        src/
        build.gradle (app gradle)

The build.gradle you have to update is normally the application gradle. You will see that it's already include some dependencies :

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    ...
}

Most library on github use Maven/Jcenter to publish the library online. Gradle take part of this and allow you to add dependencies really simply. Gradle will also merge manifest and ressources from library when you build you're app.

For FAB, the developer write in README.md the integration tutorial which include

compile 'com.melnykov:floatingactionbutton:1.3.0'

To add a library via gradle, follow this :

  1. Add gradle dependencies to you're dependencies part of you're app gradle.

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        ...
        compile 'com.melnykov:floatingactionbutton:1.3.0'
    }
    
  2. Lastly, Android Studio will prompt you to "Sync NOW", click on the button, let android download and compile the library and you're good to go.

Hugo Gresse
  • 17,195
  • 9
  • 77
  • 119
0

Clone the project first and place it in same folder as your app, then follow these steps

Community
  • 1
  • 1
Sbonelo
  • 664
  • 1
  • 9
  • 25