本文介绍了将吐司出现长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
反正是有,我可以告诉Toast通知露面只为一个指定的时间。通常短于普通敬酒消息。
Is there anyway I can tell a Toast Notification to show up only for a specified amount of time. Generally shorter then a regular toast message.
推荐答案
我找到了解决这个按一定的延迟比标准敬酒持续时间较短的后调用toast.cancel()。
I found a solution to this by calling toast.cancel() after a certain delay that is shorter than the standard toast duration.
final Toast toast = Toast.makeText(ctx, "This message will disappear in 1 second", Toast.LENGTH_SHORT);
toast.show();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
toast.cancel();
}
}, 1000);
这篇关于将吐司出现长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!