Untitled
unknown
plain_text
a year ago
852 B
16
Indexable
public void showToast() {
// Set the toast and duration
int toastDurationInMilliSeconds = 5000;
mToastToShow = Toast.makeText(this, "Hello world, I am a toast.", Toast.LENGTH_LONG);
// Set the countdown to display the toast
CountDownTimer toastCountDown;
toastCountDown = new CountDownTimer(toastDurationInMilliSeconds, 1000 /*Tick duration*/) {
public void onTick(long millisUntilFinished) {
String text= String.valueOf(millisUntilFinished/1000);
tv1.setText(text);
mToastToShow.show();
}
public void onFinish() {
mToastToShow.cancel();
}
};
// Show the toast and starts the countdown
mToastToShow.show();
toastCountDown.start();
}Editor is loading...
Leave a Comment