完成活动敬酒消息消失后? [英] Finish activity after toast message disappears?
本文介绍了完成活动敬酒消息消失后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有谁知道,如果有可能做一些事情(在我的情况下完成的活动),烤面包的消息将被关闭?
Does anybody know, if there is a possibility to do something (in my case finish activity) on toast message will be closed?
推荐答案
您这样做,仅仅通过创建一个发
长,持续为吐司
显示,然后就可以完成你的活动
。
You do that simply by creating a Thread
that lasts as long as the Toast
is displayed and then you can finish your Activity
.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// your other stuff
Toast.makeText(this,"This is a Toast", Toast.LENGTH_LONG).show();
thread.start();
}
现在创建一个线程等待(LENGTH_LONG = 3.5)或(LENGTH_SHORT = 2)秒
Thread thread = new Thread(){
@Override
public void run() {
try {
Thread.sleep(3500); // As I am using LENGTH_LONG in Toast
Your_Activity.this.finish();
} catch (Exception e) {
e.printStackTrace();
}
}
};
这篇关于完成活动敬酒消息消失后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文