मैं एक xml फ़ाइल (option_element.xml) है अंदर लेआउट जोड़ने के एक imageView और एक TextViewप्रोग्राम के रूप में एक और एक
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="-18dp" >
<ImageView
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/option_button" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button"
android:layout_alignLeft="@+id/button"
android:layout_alignRight="@+id/button"
android:layout_alignTop="@+id/button"
android:layout_centerHorizontal="true"
android:gravity="center" />
</RelativeLayout>
मैं इस दृश्य के साथ एक LinearLayout भरना चाहिए, एक सरणी
की सामग्री के आधार पर होता है<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/options_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" />
<!-- other layout elements -->
</LinearLayout>
मैं
LinearLayout options_layout = (LinearLayout) findViewById(R.id.options_list);
String[] options = getActivity().getResources().getStringArray(R.array.options);
for (int i = 0; i < options.length; i++) {
View to_add = inflater.inflate(R.layout.options_element,
options_layout);
TextView text = (TextView) to_add.findViewById(R.id.text);
text.setText(options[i]);
text.setTypeface(FontSelector.getBold(getActivity()));
}
है जैसे कि यह जोड़ रहा लेकिन कुछ गलत हो गया। मैं विकल्पों की अपेक्षा कर रहा हूं। तरंग छवि दृश्य विकल्प के साथ भरे सापेक्ष टेक्स्ट व्यू के साथ [i] पाठ, लेकिन मैं विकल्प प्राप्त करता हूं। लम्बाई छवि दृश्य, लेकिन केवल पहले व्यक्ति में टेक्स्ट होता है (और पाठ यह विकल्प नहीं है [0] तत्व, लेकिन अंतिम एक)।
उदाहरण के लिए, यदि विकल्प में पहली छवि के अंदर {"एक", "दो", "तीन"} है, तो मुझे "तीन" मिलता है, और अन्य खाली होते हैं। प्रत्येक स्ट्रिंग को प्रत्येक टेक्स्ट व्यू के अंदर कैसे रखा जा सकता है?
आप 'पाश के लिए अंदर addView' कर रहे हैं? –