0

How can I trigger a button click event through code in Android? Basically, I want to trigger the button click programmatically when some other event occurs. thank you

1 Answers1

0

We need a bit more to go on than this, which button do want to emulate being pressed when the event is triggered?

For example if you want to press the back button you can just call

onBackPressed();

inside your activity, other button actions might require more complex calls.

or if you want to press one of the buttons you have created inside your layout you can call

button.performClick();
Aedis
  • 413
  • 3
  • 6