I'm trying to implement the new Snackbars in my app but I can't. First of all I downloaded the zip file from this SnackBarSampleActivity.
I unziped it and then I import it in Eclipse. Now I get an error retrieving parent...
for the theme parent in styles.xml
.
I change it to android:Theme.Light
and the error was gone. I right clicked the project and checked isLibrary in Properties/Android, I right clicked my app and in Properties/Android I add the library. Finally I paste the code to show a Snackbar
but I get an error because Snackbar cannot be resolved
.
Please somebody help me! I'm going crazy, what am I doing wrong?
With the new Design Support Library you can use the official SnackBar Widget.
Just add this dependency to your app -> build.gradle
:
implementation 'com.android.support:design:28.0.0'
And use something like:
Snackbar.make(view, "Snackbar", Snackbar.LENGTH_LONG).show();
Full Example, In Kotlin
val fab = findViewById(R.id.btn_signin) as Button
fab.setOnClickListener(View.OnClickListener { view ->
Snackbar.make(view, "FloatingActionButton is clicked", Snackbar.LENGTH_INDEFINITE)
.setAction("Action", null).show()
})