Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clicking radio button in android programmatically?

Is there any trick to click radio button with code ? I've already tried radioButton.setChecked(true) and .setSelected(true). But that's not I want. That two methods can't trigger the event of the button. I wrote an onclick listener for each radio button that makes an EditText appears under the clicked button. So, I need a method like radioButton.click() if possible. Thanks..

like image 497
Zin Win Htet Avatar asked Oct 26 '25 03:10

Zin Win Htet


1 Answers

The setChecked and setSelected only change the state of the button. You could use performClick() to obtain a simulated click on the button.

like image 168
Alessandro Roaro Avatar answered Oct 28 '25 17:10

Alessandro Roaro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!