22 HAZİRAN 2011, ÇARŞAMBA
Nasıl Android bir RadioGroup seçilen dizin almak için
Android bir RadioGroup seçilen dizin almak için kolay bir yolu var ya OnCheckedChangeListener için değişikliklerini kullanmak zorunda mıyım ve son dizin seçili tutan bir şey var mı?
örnek xml:
<RadioGroup android:id="@ id/group1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical">
<RadioButton android:id="@ id/radio1" android:text="option 1" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<RadioButton android:id="@ id/radio2" android:text="option 2" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<RadioButton android:id="@ id/radio3" android:text="option 3" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<RadioButton android:id="@ id/radio4" android:text="option 4" android:layout_width="wrap_content" android:layout_height="wrap_content" />
<RadioButton android:id="@ id/radio5" android:text="option 5" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</RadioGroup>
eğer bir kullanıcı option 3
seçerse, 2 dizin almak istiyorum.
CEVAP
22 HAZİRAN 2011, ÇARŞAMBA
Böyle bir şey yapmak mümkün olmalıdır:
int radioButtonID = radioButtonGroup.getCheckedRadioButtonId();
View radioButton = radioButtonGroup.findViewById(radioButtonID);
int idx = radioButtonGroup.indexOfChild(radioButton);
Eğer RadioGroup
diğer Görünümler (TextView
) varsa indexOfChild()
yöntem Endeksi yanlış iade edilecektir.
Bunu Paylaş:
Nasıl android niyeti ek veri almak içi...
Nasıl Android uygulaması yapı/sürüm nu...
Nasıl'In birincil e-posta adresin...
Nasıl yüklü android uygulamaların bir ...
Nasıl bir android genişlik ve yüksekli...