当我举杯祝酒时,应用程序崩溃,但我不明白为什么。这是代码:eclipse中的吐司错误
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mvc = (Button) findViewById(R.id.button1);
mvc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),"START!" ,Toast.LENGTH_SHORT).show();
new Thread(new Runnable() {
public void run() {
long startTime = System.currentTimeMillis();
while(startTime + 5000 > System.currentTimeMillis())
{
// }
// while (progressStatus < 1000) {
if (k > progressStatus){
progressStatus = k;
}
else {
progressStatus = progressStatus;
}
// Update the progress bar and display the current value in the text view
handler.post(new Runnable() {
public void run() {
progressBar.setProgress(progressStatus);
}
});
try {
// Sleep for 10 milliseconds. Just to display the progress slowly
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Toast mioToast = Toast.makeText(BluetoothChat.this,
"STOP!",
Toast.LENGTH_LONG);
mioToast.show();
}
}).start();
}
});
第一个敬酒执行它完美,但在第二个,有单词“停止”,应用程序崩溃。怎么会这样? 谢谢。
完美!谢谢! – user3313188
不客气!请点击左边的复选标记来接受此答案。 –