这是代码:
package com.example.new_idea;
import android.app.Activity;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.SystemClock;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class second_layout extends Activity {
TextView display_temp;
Button but_temp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ui);
display_temp = (TextView) findViewById(R.id.display_temp_id);
but_temp = (Button) findViewById(R.id.button_temp_id);
Thread timer = new Thread()
{
public void run()
{
try
{
sleep(10000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
finally
{
display_temp.setText("yes , thread is working");
}
}
};
timer.start();
代码结束:) 输出通常出现在第一个,但之后(睡眠时间结束后) 该应用程序发出"停止工作的消息" 那我该怎么办?