2011-06-27 10 views
10

मैं सूची सूची में अपनी सूची आइटम प्राप्त करने का प्रयास कर रहा हूं। फिलहाल वे क्लिक करने योग्य हैं (मेरा स्क्रीनशॉट देखें) लेकिन वे पाठ के ऊपर आयत के भीतर केवल क्लिक करने योग्य हैं।ListView w/onListItem पर क्लिक करने योग्य क्षेत्र की चौड़ाई

मैं क्लिक करने योग्य सूची आइटमों के लिए protected void onListItemClick(ListView l, View v, int position, long id) { का उपयोग कर रहा हूं।

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 
<ListView android:id="@+id/android:list" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"/> 
<TextView android:id="@+id/android:empty" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/no_favorites"/> 

और मेरे row.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 
    <TextView android:id="@+id/artist" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"/> 
    <TextView android:id="@+id/songtitle" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_alignParentRight="true"/> 
    <TextView android:id="@+id/album" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_alignParentRight="true"/> 
    <TextView android:id="@+id/playtime" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_alignParentRight="true"/> 
    <TextView android:id="@+id/playlistnum" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:layout_alignParentRight="true" 
     android:visibility="gone" /> 
</LinearLayout> 

और here's the screenshot example: (न्यू उन छवियों पोस्ट करने के लिए अनुमति नहीं है

यहाँ मेरी list.xml है। .. grumble ... एक हाइपरलिंक है!)

list.xml में, सूचीदृश्य में है और रoid: layout_width = "fill_parent" तो यह स्क्रीन की पूरी चौड़ाई होना चाहिए। (Row.xml में सभी आइटम भी चौड़ाई = "fill_parent" हैं।) मुझे क्या याद आ रही है?

उत्तर

11

आपकी list.xml में टेक्स्ट व्यू को fill_parent पर सेट करने की आवश्यकता है। चयन तब माता-पिता ListView की चौड़ाई फिट होगा।

 android:layout_width="wrap_content" 
+0

कोशिश की, काम नहीं किया। उस टेक्स्ट व्यू का उपयोग केवल तभी किया जाता है जब सूची खाली हो। :/ – Civilian

+3

हमम .... आह, मेरे कोड और आपके में केवल एक ही अंतर होगा LinearLayout भी layout_width पर fill_parent पर सेट होगा। कोशिश करो। अगर यह काम नहीं करता है तो मैं अपना कोड खोलूंगा और इसे यहां पोस्ट करूंगा। – JLB

+3

स्पष्ट होने के लिए मैं आपकी आखिरी टिप्पणी में आपकी list.xml में LinearLayout का जिक्र कर रहा था। यह wrap_content पर सेट है। मेरे लिए भरने के लिए काम भरने के लिए काम किया। – JLB

संबंधित मुद्दे