Set up a Timer to run a TimerTask every 3 seconds. The TimerTask only has to call the button's setText method to change the button's text. You would have to do this within the UI thread, so you should use post to run a Runnable object that will perform the update an the correct thread.
For example, in the following activity, the letter "A" is added to the button's text every three seconds:
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");
}
});
}
}
}