private int i = 0;
private int x = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hello_world_layout);
Button b = (Button) findViewById(R.id.button);
final TextView v2 = (TextView) findViewById(R.id.t2);
new Thread() {
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
v2.setText(x++ + "");
};
}.start();
初学者 写了一个线程 。这样会出错,求解