Android Toast
Toast
- Toast is a small popup that provides simple feedback about an operation.
- It only occupies the space required to display a particular message. and also it will be shown above the current activity. i.e the current activity will remain as it is.
The basic method to display a toast is shown bellow:
String text="Hello";
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show;
NOTE: There are two constants to set the duration of toast.
1) LENGTH_SHORT: Show the view or text notification for a short period of time.
2)LENGTH_LONG: Show the view or text notification for a long period of time.
Also, we can set the position of toast on our current activity,
toast.setGravity(Gravity.TOP|Gravity.LEFT, 0, 0);
watch a video demo here:
0 comments: