日期:2014-05-17 浏览次数:20713 次
public class MasterActivity extends Activity {
TextView tv = null;
Button btn = null;
Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if(msg.what == 1) {
tv.setText("update UI is success!");
btn.setText("update UI is success!");
}
super.handleMessage(msg);
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
System.out.println(Thread.currentThread().getName() + ": " + Thread.currentThread().getId());
tv = (TextView)findViewById(R.id.text);
btn = (Button)findViewById(R.id.btn);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Thread thread = new Thread(new Runnable() {