那为什么,这段代码可以更新TextView里的内容?
package com.wo;import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;public class Ss3Activity extends Activity {
Thread otherthread = null;
private TextView tv;
private Button button; /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); tv = (TextView) this.findViewById(R.id.tv);
otherthread = new Thread("other thread") {
@Override
public void run() {
tv.setText("come baby");
} };
otherthread.start(); }
}
package com.wo;import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;public class Ss3Activity extends Activity {
Thread otherthread = null;
private TextView tv;
private Button button; /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); tv = (TextView) this.findViewById(R.id.tv);
otherthread = new Thread("other thread") {
@Override
public void run() {
tv.setText("come baby");
} };
otherthread.start(); }
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货