Is there anyway I can tell a Toast Notification to show up only for a specified amount of time. Generally shorter then a regular toast message.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
The stock Android Toast class is coded to accept only a Toast.LENGTH_SHORT or Toast.LENGTH_LONG parameter when calling a Toast. The values of these parameters are 0 and 1 respectively and do not accept any millisecond value when calling setDuration(); If you must show a Toast for a different duration than you may consider using a class from my SuperToasts library. The SuperToast class in the library is a mimic of the stock Android Toast class and can have any millisecond value used as a duration parameter. I do not recommend using this class to show a Toast longer than the maximum stock Android Toast length due to the lingering effect of these Toasts. I recommend that you use the SuperActivityToast class to show Toast messages in an Activity/Fragment because the Toast will be destroyed along with your Activity eliminating any chance of a lingering message. To use this class you may create a new object:
Or use the static method:
There are tons of customization options you can use with the library as well, check out the Wiki page!
Try this
Hope this help.. Enjoy..!!!
Here is another way to configure the time per your choice:
NOTE: The duration is specified in milliseconds.
I found a solution to this by calling toast.cancel() after a certain delay that is shorter than the standard toast duration.
You can set a longer duration by using a hack, as described here
//try it