0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RadioButtonのチェックを一つだけデフォルトでチェック状態にする方法(メモ)

Posted at

スクリーンショット 2016-12-22 午後5.56.10.png

コード上でRadioGroupにaddしていく場合

RadioGroup radioGroup = new RadioGroup(this);
    RadioButton radioBtn1 = new RadioButton(this);
    RadioButton radioBtn2 = new RadioButton(this);
    RadioButton radioBtn3 = new RadioButton(this);

    radioBtn1.setText("hoge");
    radioBtn2.setText("huga");
    radioBtn3.setText("piyo");


    radioGroup.addView(radioBtn1);
    radioGroup.addView(radioBtn2);
    radioGroup.addView(radioBtn3);
	
	// この一行がないと、他がチェック状態になってもチェックが移らない
    radioGroup.check(radioBtn1.getId());
 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?