本文介绍了我怎样才能显示举杯特定时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的样子已经显示吐司 500毫秒。虽然,它显示超过一秒。

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", 500).show();

我如何能显示吐司仅为500毫秒?

推荐答案

这不能做。要显示举杯的长度比 Toast.LENGTH_SHORT 短,你必须你想要的时间后取消。是这样的:

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 second", Toast.LENGTH_SHORT);
    toast.show();

    Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
           @Override
           public void run() {
               toast.cancel();
           }
    }, 500);

这篇关于我怎样才能显示举杯特定时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 19:05
查看更多