Reputation: 2325
I hope to use Snackbar in Android Studio, I have read http://android-developers.blogspot.sg/2015/05/android-design-support-library.html.
So I add compile 'com.android.support:design:22.2.0' in build.gradle. Snackbar.make(...) works well.
I open Projec Structure in Android Studio, I think I can find the com.android.support:design:22.2.0 item in Choose Library Dependency UI, but in fact the item isn't be listed, why?
BTW, I have updated my Android.
Choose Library Dependency Screenshot
Updated Screenshot
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "info.dodata.messagecleanup"
minSdkVersion 9
targetSdkVersion 22
versionCode 9
versionName "1.09"
archivesBaseName = "MessageCleanup-V" + versionName
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.android.support:design:22.2.0'
}
My Code
Snackbar.make(mView, "Hello SnackBar!", Snackbar.LENGTH_SHORT)
.setAction("Undo", new View.OnClickListener() {
@Override
public void onClick(View v) {
// Perform anything for the action selected
Toast.makeText(mContext, "I click Undo",Toast.LENGTH_LONG).show();
}
})
.show();
Upvotes: 2
Views: 3632
Reputation: 19
AndroidManifest.xml
with compileSdkVersion > = 22 , buildToolsVersion >= 22 (because design library only supports API >= 22)Open sdk\extras\android\m2repository\com\android\support
to know exactly the revision we have now
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
Note that we need to add two libraries with the same revision (22.2.0 or ...)
Upvotes: 2