I saw this route
View.performClick();
but it does not show the actual button click. I also tried this method,
btn.setPressed(true); btn.invalidate();
but it just shows the pressed button. I narrowed it down to this code, which pushes and releases, but does not click. Am I missing something? How can I make a full click, as if the user was clicking (monkeyrunner is not an option now)
btn = (Button) findViewById(R.id.btn_box); Handler handler = new Handler(); Runnable r = new Runnable() { public void run() { btn.setPressed(true); btn.invalidate(); Handler handler1 = new Handler(); Runnable r1 = new Runnable() { public void run() { btn.setPressed(false); btn.invalidate(); } }; handler1.postDelayed(r1, 1000); } }; handler.postDelayed(r, 1000);
EGHDK source share