2010-02-15 32 views
0

我得到ListActivity,每個項目有2個textviews圖像和CheckedTextView。我想實現簡單multichoiselist ...... 我有兩個問題:1。 onListItemClick和CheckedTextView不能重新編碼

 @Override 
     protected void onListItemClick(android.widget.ListView l, View v, 
     int position, long id) 
      { 
       ... 
       } 

犯規響應在所有我曾與調試試了一下,當我按下任何列表項它沒有停在那裏。我已經嘗試過所有種類的東西(如focusable:false

二:無論如何我不能切換CheckedTextView

這裏是我的xml:

  <?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="100sp" 
android:focusable="false" android:focusableInTouchMode="false"> 
android:padding="6dip"> 

<ImageView android:layout_width="wrap_content" 
    android:layout_height="fill_parent" android:src="@drawable/icon" 
    android:id="@drawable/icon" android:layout_marginLeft="6dip" 
    android:focusable="false" android:focusableInTouchMode="false"> 


</ImageView> 


<LinearLayout android:id="@+id/LinearLayout01" 
    android:orientation="vertical" android:layout_width="1sp" 
    android:layout_height="fill_parent" android:layout_weight="1" 
    android:focusable="false" android:focusableInTouchMode="false"> 

    <TextView android:id="@+id/toptext" android:layout_weight="1" 
     android:gravity="center_vertical" android:text="OrderNum" 
     android:singleLine="true" android:layout_height="0dp" 
     android:layout_width="wrap_content" android:focusable="false" 
     android:focusableInTouchMode="false"> 

    </TextView> 



    <TextView android:id="@+id/bottomtext" android:layout_height="wrap_content" 
     android:layout_width="wrap_content" android:focusable="false" 
     android:focusableInTouchMode="false" android:text="TweetMsg"> 
    </TextView> 


    <TextView android:id="@+id/twittLocation" 
     android:layout_weight="1" android:text="location" android:singleLine="true" 
     android:layout_width="fill_parent" android:layout_height="0dip" 
     android:focusable="false" android:focusableInTouchMode="false"> 
    </TextView> 
    <TextView android:layout_weight="1" android:id="@+id/twittLocationlink" 
     android:text="locationlink" android:gravity="fill_horizontal" 
     android:layout_width="fill_parent" android:layout_height="0dip" 
     android:focusable="false" android:focusableInTouchMode="false"> 
    </TextView> 





</LinearLayout> 




<CheckedTextView android:id="@android:id/text1" android:text="Delete" 
    android:layout_width="wrap_content" android:layout_marginRight="2dp" 
    android:layout_height="fill_parent" 
    android:checkMark="?android:attr/listChoiceIndicatorMultiple" 

    android:focusable="false"></CheckedTextView> 



</LinearLayout> 

任何想法是什麼問題? 謝謝。

+0

使用'LogCat'並留下您的代碼中調試語句,看看它被註冊。一旦你這樣做,打開'LogCat'透視窗口,看看窗口內發生了什麼。 – 2010-02-15 02:28:18

+0

我應該在logcat中尋找什麼?沒有什麼是寫在那裏關心我的問題, 什麼是必須註冊?你可以更具體請 – rayman 2010-02-15 11:40:03

+0

這可能是一個單獨的問題,這已在此處解決。做SO搜索「logcat消息不顯示」或類似的東西。 – MatrixFrog 2010-07-13 04:08:42

回答

0

在你的ListView中設置android:descendantFocusability="beforeDescendants"。這可能有幫助。

0

試試這個代碼:

public class Sample extends ListFragment implements OnItemClickListener{ 

ListView list; 

list.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { 
      @Override 
      public void onItemClick(AdapterView<?> arg0, View arg1, 
        int arg2, long arg3) { 


      } 

     }); 

} 

Sample code