2010-02-15 31 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