I have a button R1, which is dynamic and is created in an expanded form of the list, I can’t create it as publicbecause it was created at runtime many times, now the problem is that I want to change the text of the button as the timer is running. How can I change the button text in the timer start method because there is no settext method in the view.
R1 = (Button) v.findViewById(R.id.R1);
R1.setOnClickListener(new OnClickListener(){
boolean R1state=true;
TimerTask scanTask;
final Handler handler = new Handler();
Timer t = new Timer();
boolean time=true;
@Override
public void onClick( View v) {
scanTask = new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
});
}};
if(!R1state)
{v.getBackground().setColorFilter(Color.GREEN, Mode.ADD);
t.cancel();
v.setEnabled(false);
}
else
{ t.schedule(scanTask, 300, 30000);
v.getBackground().setColorFilter(Color.RED, Mode.ADD);
R1state=false;
}
;
}
});;
source
share