2013-03-12 3 views
8

मुझे सूचीदृश्य के साथ कुछ समस्या है। लिस्टव्यू में सूची आइटम हैं जिनमें छविदृश्य और टेक्स्टव्यू शामिल हैं। टेक्स्टव्यू में क्लिक करने योग्य लिंक हैं। जब मैं LinkMovementMethod को टेक्स्टव्यू पर सेट करता हूं, तो सूचीकरण को ऑनक्लिक ईवेंट प्राप्त नहीं होता है। मैं अभी भी किसी भी सही समाधान = (नहीं मिल सकता है किसी को भी यह कैसे हल करने के लिए या अंदर ListItem धन्यवाद क्लिक करने योग्य लिंक के साथ TextView का उपयोग करने का एक उदाहरण देता explane सकते हैं यहाँ अनुकूलक में TextView रचना है:।?।टेक्स्टव्यू का लिंकमोवमेंट विधि ब्लॉक सूची टच इवेंट

TextView text = (TextView) ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) 
         .inflate(R.layout.post_content_text, null); 
SpannableString sString = new SpannableString(d.getText()); 
//I have my own class UrlSpan that contain fields startPosition, endPosition and urlLink 
for (UrlSpan us : ((TextData) d).getUrls()) 
       { 
        URLSpan urlSpan = new URLSpan(us.getUrl()); 
        sString.setSpan(urlSpan, us.getStart(), us.getEnd(), SpannableString.SPAN_INCLUSIVE_INCLUSIVE); 
       } 
text.setText(sString); 
text.setMovementMethod(LinkMovementMethod.getInstance()); 
view.addView(text); 

और सूची आइटम है: दस्तावेज़ से अपने सूचीदृश्य

से इस विशेषता को android:descendantFocusability="beforeDescendants" जोड़ने के लिए

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:visibility="visible" > 

    <LinearLayout 
     style="?PostListRow" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_margin="10dp" 
     android:orientation="vertical" 
     android:padding="10dp" > 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="65dp" 
      android:orientation="horizontal" > 

      <ImageView 
       android:id="@+id/user_image" 
       android:layout_width="45dp" 
       android:layout_height="45dp" 
       android:layout_margin="3dp" 
       android:clickable="true" 
       android:src="@drawable/ic_no_photo" /> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="55dp" 
       android:layout_margin="0dp" 
       android:orientation="vertical" > 

       <TextView 
        android:id="@+id/user_title" 
        android:layout_width="fill_parent" 
        android:layout_height="0dp" 
        android:layout_weight="1" 
        android:clickable="true" 
        android:textSize="@dimen/title_in_list" /> 

       <TextView 
        android:id="@+id/post_datetime" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="5dp" 
        android:layout_marginTop="5dp" 
        android:textSize="@dimen/text_size_small" /> 
      </LinearLayout> 

      <TextView 
       android:id="@+id/post_number" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="right" 
       android:text="123" /> 
     </LinearLayout> 
<!-- it is a view where textview with links is to be added to --> 
     <LinearLayout 
      android:id="@+id/post_data" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:weightSum="6" > 
     </LinearLayout> 

     <TextView 
      android:id="@+id/post_view" 
      style="?PostText" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="TextView" 
      android:visibility="gone" /> 

     <LinearLayout 
      android:id="@+id/topic_edit_view" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" > 
     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 
+0

अपना कोड डालें। यदि आपके पास कस्टम एडाप्टर है तो अपने एडाप्टर कोड को क्लिकलिस्टर के साथ रखें ... –

+1

मैं आपकी पोस्ट में आया और मुझे विश्वास है कि इसे हल किया गया है: https://stackoverflow.com/questions/8558732/listview-textview-with- linkmovementmethod-makes-list-item-unclickable – m3hughes

उत्तर

0

कोशिश:

+०१२३५१६४१०

यह ध्यान केंद्रित करने के लिए एक दृश्य की तलाश करते समय व्यू ग्रुप और इसके वंशजों के बीच संबंध को परिभाषित करता है। ऐसा लगता है कि जब आपके पास अपनी सूचीदृश्य में बटन या एडिटेक्स्ट आदि जैसे कुछ सक्रिय दृश्य होते हैं तो आपको वंशज को परिभाषित करना होगा फोकसबिलिटी

+0

आप यह समझा सकते हैं कि यह विशेषता क्या जोड़ती है। डॉक्स से – deW1

+0

फोकस करने के लिए एक दृश्य की तलाश करते समय व्यू ग्रुप और इसके वंशजों के बीच संबंध को परिभाषित करता है। मुझे ऐसा लगता है कि जब आपके पास अपनी सूचीदृश्य में बटन या एडिटेक्स्ट आदि जैसे कुछ सक्रिय दृश्य होते हैं तो आपको वंशज को परिभाषित करना होगा फोकसबिलिटी – greenfrvr

+0

वंश दृश्यशीलता को अवरुद्ध करना एक सूची दृश्य में स्पैन करने योग्य स्ट्रिंग और LinkMovementMethod का उपयोग करते समय काम नहीं करता है। शायद आप इस एसओ स्वीकृत उत्तर से दृष्टिकोण का प्रयास कर सकते हैं ... http://stackoverflow.com/questions/8558732/listview-textview-with-linkmovementmethod-makes-list-item-unclickable – Dallas187

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