package com.example.hellol10n;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.TextView;
public class HelloL10N extends Activity {
private TextView txtStatus;
private TextView txtViewer;
private RefreshHandler mRedrawHandler = new RefreshHandler();
class RefreshHandler extends Handler {
@Override
public void handleMessage(Message msg) {
HelloL10N.this.updateUI();
}
public void sleep(long delayMillis) {
this.removeMessages(0);
sendMessageDelayed(obtainMessage(0), delayMillis);
}
};
private void updateUI(){
int currentInt = Integer.parseInt((String) txtStatus.getText()) + 10;
if(currentInt <= 100){
mRedrawHandler.sleep(1000);
txtStatus.setText(String.valueOf(currentInt));
txtViewer.setText(String.valueOf(currentInt*100));
}
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
this.txtStatus = (TextView) this.findViewById(R.id.TimerView);
this.txtViewer = (TextView) this.findViewById(R.id.StatusView);
updateUI();
}
}
No comments:
Post a Comment