출처는 스택오버플로닷컴
public class ButtonTest extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Button subject = new Button(this);
subject.setLayoutParams((new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT)));
subject.setText("A");
setContentView(subject);
Timer timing = new Timer();
timing.schedule(new Updater(subject), 3000, 3000);
}
private static class Updater extends TimerTask {
private final Button subject;
public Updater(Button subject) {
this.subject = subject;
}
@Override
public void run() {
subject.post(new Runnable() {
public void run() {
subject.setText(subject.getText() + "A");
}
});
}
}
}
본 블로그는 페이스북 댓글을 지원합니다.