Saturday, 31 August 2013

Timer for an editText Box : Only the original thread that created a view hierarchy can touch its views

Timer for an editText Box : Only the original thread that created a view
hierarchy can touch its views

I am trying to make the edittext boxvibrate and change color momentarily
if a wrong password is entered
final Drawable oldBackground = findViewById(R.id.email).getBackground();
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
MainActivty.this.findViewById(R.id.password).setBackground(oldBackground);
MainActivty.this.findViewById(R.id.email).setBackground(oldBackground);
}
};
Toast.makeText(MainActivty.this , valArray.get(0).toString(),
Toast.LENGTH_SHORT).show();
findViewById(R.id.password).setBackgroundColor(Color.RED);
findViewById(R.id.email).setBackgroundColor(Color.RED);
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(500);Timer timer = new Timer();
timer.schedule(timerTask, 1000);

No comments:

Post a Comment