android - How to dynamically add radiobuttons and not lose view contents -


मेरा लेआउट इस तरह दिखता है

  & lt;? Xml संस्करण = "1.0" एन्कोडिंग = "utf-8" & gt; & Lt; LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" एंड्रॉइड: अभिविन्यास = "ऊर्ध्वाधर" एंड्रॉइड: layout_width = "fill_parent" एंड्रॉइड: layout_height = "wrap_content" & gt; & Lt; TextView android: layout_width = "fill_parent" एंड्रॉइड: layout_height = "wrap_content" एंड्रॉइड: textStyle = "bold" android: text = "कृपया उस रेस्तरां का चयन करें जिसे आप रेट करना चाहते हैं:" / & gt; & Lt; RadioGroup android: layout_width = "fill_parent" एंड्रॉइड: layout_height = "wrap_content" एंड्रॉइड: अभिविन्यास = "ऊर्ध्वाधर" एंड्रॉइड: आईडी = "@ + आईडी / चयनरेस्टोरिटी" & gt; & Lt; / RadioGroup & gt; & Lt; बटन एंड्रॉइड: layout_width = "100px" एंड्रॉइड: layout_height = "wrap_content" एंड्रॉइड: टेक्स्ट = "इसे रेट करें" एंड्रॉइड: id = "@ + id / submitSelection" / & gt; & Lt; / LinearLayout & gt;   

जब मैं जावा फाइल में रेडियोगुटन्स को जोड़ता हूं, तो रेडियबुटोन एक-दूसरे पर ओवरलैप कर रहे हैं और बटन सबमिट किया गया है। मुझे लगता है कि रेडियोबूटन्स दृश्य के अन्य तत्वों को ओवरराइड कर रहे हैं।

जावा कोड इस तरह दिखता है:

  setContentView (R.layout.submit_select); मैं अन्य तत्वों को खोए बिना इन रेडियो बटनों को गतिशील रूप से कैसे जोड़ सकता हूं। रेडियो ग्रुप रेडियो समूह = (रेडियोसमूह) खोजव्यूबीआईआईडी (आरआईड। सेलेक्ट रेस्टैरर्ट); के लिए (स्ट्रिंग रेस्तरां: रेस्तरां) {रेडियोबटन रेडियोबटन = नया रेडियोबटन (getBaseContext ()); radioButton.setText (रेस्तरां); radioGroup.addView (radiobutton); } RadioGroup.invalidate (); dismissDialog (DIALOG_SUBMIT_ID); दरItButton = (बटन) ढूंढिए ViewById (R.id.submitSelection); rateItButton.setOnClickListener (this); चौड़ाई और ऊंचाई के लिए WRAP_CONTENT के साथ लेआउट पैरामीटर बनाने का प्रयास करें और फिर लेआउट पैरामीटर जोड़ते समय    

आप समूह में बटन जोड़ते हैं: <पूर्व> radiogroup.addView (newRadioButton, layoutParams);

Comments

Popular posts from this blog

android - How can I execute default sms app? -

jquery .css('text-decoration') doesn't work from parents -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -