मैं Android विकास के लिए नया हूँ। मैंने इंटरफ़ेस की तरह ListView के साथ एक गतिविधि बनाई है, लेकिन ListView का उपयोग किए बिना सूची में प्रत्येक आइटम (पंक्ति) में अलग-अलग तत्व हो सकते हैं। मैंने स्क्रॉलव्यू के अंदर LinearLayouts को शामिल करके इसे सफलतापूर्वक बनाया है, लेकिन XML गन्दा दिखता है। मैंने प्रत्येक आंतरिक LinearLayouts में onClickListener को भी जोड़ा है।
क्या ऐसा करने का कोई बेहतर तरीका है?
धन्यवाद।
सादर,
डेज़ुल्
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<LinearLayout
android:id="@+id/LinearLayout02"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/wo_status_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/desc_button"
android:focusable="true"
android:padding="3dp">
<TextView
android:id="@+id/wo_status"
android:text="@string/wo_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/wo_status"
android:text="Waiting for Parts"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="@+id/wo_prob_desc_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@color/desc_button"
android:focusable="true"
android:padding="3dp">
<TextView
android:id="@+id/wo_prob_desc"
android:text="@string/wo_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/wo_prob_desc"
android:text="New problem"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
2 जवाब
मैं लेजरिस्ट के लिए प्रमुख डेवलपर हूं। हमने जो किया वह एडॉप्टर का एक उपवर्ग था जिसने ऊपर बताए अनुसार getView को लागू किया।
GetView विधि के अंदर, आप एक ViewHolder ऑब्जेक्ट बनाएंगे क्योंकि मुझे यकीन है कि पूरे वेब पर कई ट्यूटोरियल में दिखाया गया है। आप प्रत्येक नियंत्रण का एक उदाहरण बनाना चाहेंगे जिसे आप व्यूहोल्डर के अंदर दिखाना चाहते हैं। जब आप सेल को लागू करना शुरू करते हैं, तो आप उन सभी नियंत्रणों को सेट करना चाहेंगे जिन्हें आप GONE पर उनकी सेट विज़िबिलिटी विधि का उपयोग करके प्रदर्शित नहीं करना चाहते हैं।
आशा है कि यह मददगार है,
जेम्स के., लीड डेवलपर www.vervv.com | support@vervv.com
ट्विटर पर हमें फॉलो करें: @vervv http://twitter.com/vervv
आप एडेप्टर को उपवर्गित कर सकते हैं और getView () को लागू कर सकते हैं; एडेप्टर आपको एक से अधिक व्यू का उपयोग करने देता है और आप किसी के लिए भी ऑनक्लिक लिस्टनर सेट कर सकते हैं; अपने पसंद के बच्चों के साथ रेखीय लेआउट को फिर से शुरू करना; एंड्रॉइड में पहले से ही विभिन्न उद्देश्यों के लिए एडेप्टर उपवर्ग हैं; ArrayAdapter, SimpleAdapter, CursorAdapter, ..etc; फिर ListView.setAdapter(yourAdapter);
स्क्रॉल व्यू के साथ एडेप्टर का उपयोग करने के लिए एक और चाल है; LinearLayout को स्क्रॉलव्यू चाइल्ड के रूप में सेट करें, फिर LinearLayout.addview(adapter.getView(...));
आशा है कि यह मदद करता है;
संबंधित सवाल
नए सवाल
android
एंड्रॉइड Google का मोबाइल ऑपरेटिंग सिस्टम है, जिसका उपयोग प्रोग्रामिंग या डिजिटल डिवाइस (स्मार्टफोन, टैबलेट, ऑटोमोबाइल्स, टीवी, वियर, ग्लास, IoT) को विकसित करने के लिए किया जाता है। एंड्रॉइड से संबंधित विषयों के लिए, एंड्रॉइड-विशिष्ट टैग जैसे कि एंड्रॉइड-इरादे, एंड्रॉइड-गतिविधि, एंड्रॉइड-एडॉप्टर आदि का उपयोग करें। विकास या प्रोग्रामिंग के अलावा अन्य प्रश्नों के लिए, लेकिन एंड्रॉइड फ्रेमवर्क से संबंधित हैं, इस लिंक का उपयोग करें: https: // android.stackexchange.com।