xml
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rg"
android:paddingTop="3dp">
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="개"
android:id="@+id/radioDog" />
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="고양이"
android:id="@+id/radioCat" />
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="토끼"
android:id="@+id/radioRat" />
</RadioGroup>
java
final RadioGroup rg = (RadioGroup) findViewById(R.id.rg);if(rg.getCheckedRadioButtonId()==R.id.radioDog){
}
else if(rg.getCheckedRadioButtonId()==R.id.radioCat){
}
else if(rg.getCheckedRadioButtonId()==R.id.radioRat){
}
'기초 > android' 카테고리의 다른 글
부분 화면 뿌리기 (0) | 2015.05.26 |
---|---|
RelativeLayout (0) | 2015.05.21 |
안드로이드 widget 참고사항 (0) | 2015.05.20 |
안드로이드 키보드 보이기/숨기기, 포커스 주기, 숫자입력 (0) | 2015.05.20 |
안드로이드 TextView 글자 크기 (0) | 2015.05.20 |