This is the way I have to show the Toast for 500 milliseconds. Though, it\'s showing more than a second.
Toast.makeText(LiveChat.this, \"Typing\
I tried different method and this method works for me
final Toast mytoast = Toast.makeText(getApplicationContext(), jsonObject.getString("response_message"), Toast.LENGTH_SHORT);
mytoast.show();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
mytoast.cancel();
}
}, 5000);// 5 sec
I have created a class ToastMessage in droid side.
public class ToastMessage: IToast
{
public void LongAlert(string message)
{
Toast toast = Toast.MakeText(Android.App.Application.Context, message, ToastLength.Short);
toast.Show();
Device.StartTimer(TimeSpan.FromSeconds(0.5), () =>
{
toast.Cancel();
return false;
});
}
}
I have created interface IToast
public interface IToast
{
void LongAlert(string message);
}
Calling By Dependency Service
DependencyService.Get<IToast>().LongAlert("Right Answer");
Can't do what you are asking with the standard Toasts. Perhaps you should think about integrating a 3rd party library that gives you better Toast options (named Crouton). I haven't used it myself, but people seem to like it.
You can't control the length of Toasts in the standard OS.
Crouton link: https://github.com/keyboardsurfer/Crouton
Toast.makeText(LiveChar.this,"Typing",Toast.LENGTH_SHORT);
This is the only way you can..
This cannot be done. To show a toast for a length shorter than Toast.LENGTH_SHORT, you must cancel it after the time you want. Something like:
final Toast toast = Toast.makeText(getApplicationContext(), "This message will disappear in half a second", Toast.LENGTH_SHORT);
toast.show();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
toast.cancel();
}
}, 500);
I don't believe this can be done, you can only use Toast.LENGTH_LONG or Toast.LENTH_SHORT you can't define your know speed.