为什么我的不会抛出异常???
package com.example.handler_01;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity {
private TextView tv1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv1=(TextView) findViewById(R.id.tv1);
/*
* 直接在非主线程中更新UI会抛出异常:
* */
new Thread(){
public void run() {
try {
Thread.sleep(1000);
tv1.setText("thread update.....");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
};
}.run();
}
}