मैं एक्सएमएलRadioGroup: कैसे प्रोग्राम के रूप में जांच करने के लिए
<RadioGroup android:id="@+id/option"
android:layout_width="match_parent"
android:orientation="horizontal"
android:checkedButton="@+id/block_scenario_off"
android:layout_height="wrap_content">
<RadioButton
android:layout_width="0dip"
android:layout_weight="1"
android:text="@string/option1"
android:layout_height="wrap_content"
android:id="@+id/option1"
android:layout_gravity="center|left"
android:onClick="@string/on_click"/>
<RadioButton
android:layout_width="0dip"
android:layout_weight="1"
android:text="@string/option2"
android:onClick="@string/on_click"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/option2"/>
<RadioButton
android:layout_width="0dip"
android:layout_weight="1"
android:text="@string/option3"
android:onClick="@string/on_click"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:id="@+id/option3" />
</RadioGroup>
जावा कोड में से एक RadioGroup बनाने के लिए, मैं प्रोग्राम के रूप में निम्नलिखित के रूप में गतिविधि निर्माण (OnCreate()) पर पहले एक जाँच:
mOption = (RadioGroup) findViewById(R.id.option);
mOption.check(R.id.option1);
लेकिन जब गतिविधि दिखायी जाती है, तो कोई रेडियो बटन चेक नहीं किया जाता है। कोई मदद?
यदि आप चाहते थे रेडियो बटन को प्रोग्रामेटिक रूप से जांचें, तो आपको उस उत्तर को स्वीकार नहीं करना चाहिए था, इस तरह हम उन्हें xml फ़ाइल पर चेक करते हैं! – arniotaki