Recent Posts
Recent Comments
반응형
«   2025/08   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Archives
Today
Total
관리 메뉴

오늘도 공부

RadioButton group(그룹)으로 사용하기 본문

Android

RadioButton group(그룹)으로 사용하기

행복한 수지아빠 2011. 11. 16. 15:36
반응형
잘안쓰지만 언젠가는 사용할일이 있겠지 싶은 물건.
주의할점이라고 하면 RadioGroup , RadioButton은 직계 부모 자식 간이어야 합니다.
	<RadioGroup android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/sex"
android:orientation="horizontal">
<RadioButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/male"
android:text="@string/male"></RadioButton>
<RadioButton android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/female"
android:text="@string/female"></RadioButton>
</RadioGroup>
먼저 그룹값을 가져온뒤
	RadioGroup sexGroup = (RadioGroup) findViewById(R.id.sex);
그중에 선택퇸 라디오버튼을 다시한번 가져와서
	RadioButton sex = (RadioButton) findViewById(sexGroup.getCheckedRadioButtonId());
그것의 라벨내용을 사용합니다.
	sex.getText().toString();
반응형