【发布时间】:2014-07-15 10:46:21
【问题描述】:
我正在开发一个测验应用程序,我在其中使用可运行线程来实现搜索栏功能。搜索栏显示剩余时间。现在我想在单击答案按钮时停止搜索栏。
这是我的可运行线程代码。
new Thread(new Runnable() {
public void run() {
while (seekbarStatus < 100) {
seekbarStatus = LoadingStatus();
// sleep 1 second to show the progress
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
// Update the progress bar
progressBarHandler.post(new Runnable() {
public void run() {
seekbar.setProgress(seekbarStatus);
}
});
}
if (seekbarStatus >= 100) {
// sleep for 2 seconds, so that you can see the 100% of file download
runOnUiThread(new Runnable() {
@Override
public void run() {
if(!(Ans_1.getTag()=="clicked" ||Ans_2.getTag()=="clicked" || Ans_3.getTag()=="clicked" ))
{
Ans_1.setEnabled(false);
Ans_2.setEnabled(false);
Ans_3.setEnabled(false);
Ans_1.setBackgroundColor(Color.GREEN);
points.setText("0 Punkt");
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
/* Create an Intent that will start the Menu-Activity. */
showDialogView();
}
}, SPLASH_DISPLAY_LENGHT);
}
}
public void showDialogView() {
// TODO Auto-generated method stub
dialog.show();
}
});
}
}
}).start();
请帮助我。任何帮助将不胜感激。
我不知道如何解决它。
提前致谢。
【问题讨论】: