0

Android Toast can be Set for a certain time without using Toast.LENGTH_LONG or Toast.LENGTH_SHORT.

That can be achieved with very simple Code:

private void customToast{
 long delayTimeForToast = 3500 //3.5sec

 Toast.makeText(getApplicationContext(),"Your TEXT", (int)toastDelayTime).show();
}

That Toast can visible for 3.5 sec

bart
  • 1,003
  • 11
  • 24

1 Answers1

0

Try this reference from page show a Toast for a specific duration

private Toast mToastToShow;
public void showToast(View view) {
    // Set the toast and duration
    int toastDurationInMilliSeconds = 10000;
    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) {
          mToastToShow.show();
      }
      public void onFinish() {
         mToastToShow.cancel();
         }
    };

    // Show the toast and starts the countdown
    mToastToShow.show();
    toastCountDown.start();
}
TejpalBh
  • 427
  • 4
  • 13