简体   繁体   中英

Can I set default button is clicked or selected in android?

I want to do something like when I start the activity, "button A" is clicked ( or selected) as default , a String will be shown immediately in the textview. And there is another Button, "button B". When I click on it, "button A" isSelected set to be false and "button B" isSelected set to be true, show required "button b" text.

I am already done the button change text when isSelected(), I just cannot set one of it as default "clicked" or "selected", can anyone help?

I consider you can use RadioGroup for this case. More details here

您在找这个吗?

mButton.setSelected(true);

您可以创建该按钮的OnClick函数,然后在onCreate()中调用它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM