I need to refresh TextViews every 5 seconds, I have created TimerTask( and set Activity like parameter in contrsuctor) but I got error that I can access widgets only from thread which created them.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.system_data_show);
currentActivity = this;
Timer timer = new Timer();
timer.schedule(new SystemTimerTask(currentActivity),500, 5000);
///////////////// text views from layout /////////////////////////////////////////////
TextView txtCapture = (TextView) this.findViewById(R.id.txtCapture);
txtCapture.setText("System Data");
TextView txtWorkAllowedValue=(TextView)this.findViewById(R.id.workAllowedValue);
TextView txtBusBroken0Value=(TextView)this.findViewById(R.id.busBroken0Value);
TextView txtBusBroken1Value=(TextView)this.findViewById(R.id.busBroken1Value);
TextView txtShortCircuit0Value=(TextView)this.findViewById(R.id.shortCircuit0Value);
TextView txtShortCircuit1Value=(TextView)this.findViewById(R.id.shortCircuit1Value);
TextView txtErrorConfigurationValue=(TextView)this.findViewById(R.id.errorConfigurationValue);
}
How to refresh this textViews on every 5 seconds ? Is there any way not to extend TimerTask, maybe o implement some interface ( I don't know which) so my SActivity extends Activity implements thatInterface ?