wehweh
wehweh

Reputation: 67

Android Button programmatic click

I have a button. I want to simulate a click on. performClick() does most of the job, but it doesn't do the button's animation. I tried setPressed and setEnabled as well, but no dice.

Upvotes: 0

Views: 3709

Answers (2)

Xavi Gil
Xavi Gil

Reputation: 11568

Call invalidate after the setPressed to force the view to redraw:

btn.setPressed(true);
btn.invalidate();

Upvotes: 7

Try to use tool Monkey.

Upvotes: 0

Related Questions