3

I am trying to set the snack bar length using this:

Snackbar oSnackbar = Snackbar.make(Context, "Testing", Snackbar.LENGTH_LONG);
oSnackbar.setDuration(8000);
oSnackbar.show();

But I get this compile error in setDuration:

Must be one of Short, Long or Indefinite

In Android Studio gradle I use the dependency:

compile 'com.android.support:design:23.0.1'

Any Help?

Ton
  • 9,235
  • 15
  • 59
  • 103
  • 1
    check: http://stackoverflow.com/questions/30550792/how-to-use-setduration-method-in-snackbar-android-design-support-library – csenga Nov 27 '15 at 18:18
  • What I see there is that it was a bug that was solved with revision 22.2.1. But I am using 23.0.1 and still having the issue. – Ton Nov 27 '15 at 18:23
  • I tried your code, but i do not get the error. – csenga Nov 27 '15 at 18:36
  • Now i got it. I tried 22.2.0 and 23.0.1 versions. Using 22.2.0 no error, but if i change to 23.0.1, resync the project with gradle, then i got the same error too. – csenga Nov 27 '15 at 18:40
  • Oh wow. Did they make the same mistake twice? – Ton Nov 27 '15 at 18:45
  • According to this:http://developer.android.com/tools/support-library/features.html#design , 23.1.0 is the latest version. With it, your code compiles fine, although setDuration's parameter is underlined. – csenga Nov 27 '15 at 18:52
  • Oh I see. It is underlined in red and if you put the mouse on it it displays the error BUT it works. Thanks! – Ton Nov 27 '15 at 18:58
  • 1
    By the way, I updated to 23.1.1 and now it is not underlined in red. – Ton Nov 27 '15 at 18:59

1 Answers1

0

You just need to update the SDK version you are using to 23.0.1

Reference : http://androidgifts.com/android-material-design-snackbar/

Fareed
  • 560
  • 2
  • 7
  • 23