From google material design documentation . Android also provides a toast, primarily used for system messaging. Toasts are similar to snackbars but do not contain actions and cannot be swiped off screen. How to add? Create Toast instance with make() method. Then call show() method. Toast.makeText(context, "No network connection.", duration).show(); To specify how long Toast will be visible on screen use duration parameter of makeText() method or setDuration method. // you can use only those 2 predefined constants duration = Toast.LENGTH_SHORT; // 2000 millis duration = Toast.LENGTH_LONG; // 3500 millis toast.setDuration(duration); To hide Toast manually at any time use cancel() method. Toast toast= Toast.make(view, text, duration).show(); toast.cancel(); //hide toast Close the view if it's showing, or don't show it if it isn't showing yet. You do not normally have to call this. Normally view will disappear on its own after the appro...
Comments
Post a Comment