В моем приложении Android я имитирую нажатие кнопки с помощью следующего кода:
void clickButton(final Button b, int delay)
{
final Handler handler = new Handler();
handler.postDelayed(new Runnable()
{
public void run()
{
final Drawable drawable = b.getBackground();
b.performClick();
b.getBackground().setColorFilter(b.getContext().getResources().getColor(R.color.colorAccent), PorterDuff.Mode.MULTIPLY);
// b.setBackgroundColor(Color.rgb(88, 166, 198));
b.setPressed(true);
b.invalidate();
// delay completion till animation completes
b.postDelayed(new Runnable() { //delay button
public void run() {
b.setPressed(false);
b.invalidate();
b.setBackground(drawable);
//any other associated action
}
}, 800); // .8secs delay time
}
}, delay);
}
Но цвет кнопки будет оставаться зеленым после нажатия, как его вернуть обратно в цвет до щелчок после задержки .5 se c?