T = new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { if (edittext1.getText().toString().equals("")) { button1.setBackground(new GradientDrawable() { public GradientDrawable getIns(int a, int b, int c, int d) { this.setCornerRadius(a); this.setStroke(b, c); this.setColor(d); return this; } }.getIns((int)20, (int)5, 0xFFBDBDBD, 0xFF7986CB)); } else { button1.setBackground(new GradientDrawable() { public GradientDrawable getIns(int a, int b, int c, int d) { this.setCornerRadius(a); this.setStroke(b, c); this.setColor(d); return this; } }.getIns((int)20, (int)5, 0xFFBDBDBD, 0xFF3D5AFE)); } } }); } }; _timer.scheduleAtFixedRate(T, (int)(0), (int)(10)); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View _view) { if (edittext1.getText().toString().equals("")) { ((EditText)edittext1).setError("မှားနေပါ သည်"); } } });