嗨
今天我的问题是关于线程,在Android的活动,我想显示一条消息,图标一个对话框,标题和三个按钮(正面,负面和中性),我已经做到了,没有任何错误(加上听众和一切),我执行正常,并再次没有错误,问题是这样的:Android的线程问题(线程在后台运行)
alert.setPositiveButton("Yes", new android.content.DialogInterface.OnClickListener(){
public void onClick(DialogInterface i, int j)
{
pb.setVisibility(0); //pb is a progress bar
new Thread (new Runnable()
{
public void run()
{
try {
tv.setText("Saved!");
Thread.sleep(5000);
tv.setText(null); //tv is a text view
Thread.sleep(5000);
finish();
} catch (InterruptedException e) {
alerttmp.setIcon(R.drawable.ic_launcher);
alerttmp.setTitle("Error");
alerttmp.setMessage("Thread could not be executed Thread id: 100390");
alerttmp.show();
}
}
}).run();
}
});
见,突出显示正的按钮并保持高亮显示,直到活动关闭,同时我希望对话框消失时,按钮显示,电视有文字“保存!!”在其中,然后没有文字,并最终杀死该活动。
SOS的家伙!谢谢!
ps:英语不是我的母语,所以没有莎士比亚的话请! :)请让语言尽可能简单!谢谢!
我也跑它的UIThread,没有工作,直到我选择它可能仍然没有工作 –