Use a Handler:
public TextView pc;
Handler handler = new Handler();
oncreate(..) {
setContentView(R.layout.main);
pc = new TextView(context);
Thread t =new Thread(){
public void run() {
handler.post(new Runnable() {
public void run() {
pc.setText("test");
}
});
}
}};
t.start();
}
But you have another problem. pc
points to a view that is not part of your hierarchy. You probably want to use findViewById
with the id of the TextView in your layout.