Sunday 15 September 2013

how to add an xml file dynamically multiple times for the same ViewGroup in android -


मेरे पास एक XML फ़ाइल है जिसे

rowitem.xml <पूर्व> & lt; LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" एंड्रॉइड: id = "@ + id / item" एंड्रॉइड: layout_width = "fill_parent" एंड्रॉइड : Layout_height = "fill_parent" & gt; & Lt; TextView एंड्रॉइड: id = "@ + id / name" एंड्रॉइड: layout_width = "wrap_content" एंड्रॉइड: layout_height = "wrap_content" / & gt; & Lt; ImageButton एंड्रॉइड: id = "@ + id / pic" एंड्रॉइड: layout_width = "wrap_content" एंड्रॉइड: layout_height = "wrap_content" एंड्रॉइड: contentDescription = "@ null" / & gt; & Lt; / LinearLayout & gt;

और मुझे यह लेआउट तालिका स्तंभ में प्रत्येक कॉलम आइटम में जोड़ना चाहते हैं

  के लिए (int raw = 0; raw & lt; 5; raw ++) { टेबलरॉ टेबलरॉ = नया तालिकारॉ (यह); tableRow.setOrientation (TableRow.HORIZONTAL); // यहां मैं एक ही पंक्ति में लगभग 4 बार समान rowitem.xml जोड़ना चाहता हूं}   

मैंने इसे inflater के साथ प्राप्त करने की कोशिश की लेकिन यह काम नहीं करता

इसे आज़माएं ..

  लेआउटइनफ्लेर vi = (लेआउट इनफ्लाटर) getSystemService (संदर्भ। LEOUT_INFLATER_SERVICE); टेबलरॉ टेबलरॉ = नया तालिकारॉ (यह); tableRow.setOrientation (TableRow.HORIZONTAL); (इंट कच्चे = 0; कच्चे और लेफ्टिनेंट; 5; कच्चे ++) के लिए {देखें वी = वीआईएनफलेट (आर। लेटाओ.ओआईआईटीम, रिक्त); // यहाँ मैं एक ही rowitem.xml को एक ही पंक्ति tableRow .addView (v) में लगभग चार बार जोड़ना चाहता हूं; }    

No comments:

Post a Comment