After updating targetSDK to 28 ,Snackbar is giving error?

问题: After updating my targetSDK version to 28, I am not able to use the SnackBar Must be one of BaseTransientBottomBar.LENGTH_INDEFINITE, BaseTransientBottomBar.LENGTH_SH...

问题:

After updating my targetSDK version to 28, I am not able to use the SnackBar

Must be one of BaseTransientBottomBar.LENGTH_INDEFINITE, BaseTransientBottomBar.LENGTH_SHORT, BaseTransientBottomBar.LENGTH_LONG or value must be ≥ 1 (was -2) less... Inspection info: Ensures that when parameter in a method only allows a specific set of constants, calls obey those rules.

My Sample Code

Here is what I have done -

Snackbar snackbar = Snackbar.make(Objects.requireNonNull(parentLayout), "Kindly allow all the permissions for  App  for a better  experience...", Snackbar.LENGTH_LONG);
 snackbar.setDuration(Snackbar.LENGTH_INDEFINITE);
 snackbar.show();

回答1:

Read setDuration

snackbar.setDuration(int duration);

Set how long to show the view for. You should try with

snackbar.setDuration(10000);
  • 发表于 2019-07-07 23:18
  • 阅读 ( 417 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除