0

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?

kris ho
  • 51
  • 1
  • 9

3 Answers3

2

Are you looking for this?

mButton.setSelected(true);
Joel Min
  • 3,387
  • 3
  • 19
  • 38
  • ya, I have set one of the button as true and the others as false when I " click" it. I want to do is set one of it is true as default before i clicked it or when i enter the activity. – kris ho Sep 08 '15 at 09:32
  • Then you could put 'mButton.setSelected(true)' in your 'onCreate()' where your activity is created. – Joel Min Sep 08 '15 at 09:44
  • Glad to be of help :) – Joel Min Sep 08 '15 at 10:05
2

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

0

You can create a OnClick function of that button, and call it in onCreate().

nguoixanh
  • 199
  • 1
  • 10