2012-11-29 42 views
0

嗨在我的应用程序我想要做一些功能点击列表中的项目。Onitem单击列表工具不能在列表视图

这是列表项的xml。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:background="#FFFFFF" 
    android:layout_marginTop="20dp" 
    android:focusableInTouchMode="true" android:focusable="true"> 

    <TableLayout android:layout_width="fill_parent" android:layout_marginTop="10dp" 
     android:layout_height="wrap_content" android:id="@+checklistitem/itemrow"> 
     <TableRow android:id="@+checklistitem/tr"> 
      <TextView android:id="@+checklistitem/texthead" 
      android:textStyle="bold" 
      android:visibility="gone" android:layout_marginLeft="10dp" 
       android:layout_width="fill_parent" android:layout_height="fill_parent" 
       android:paddingRight="0dp" android:maxLines="2" android:textSize="16dp" 
       android:text="Towel Rack: 2 hand towels,2 wash clothes" 
       android:background="#000000" android:textColor="#ffffff" 
       android:layout_centerVertical="true" /> 

      <TextView android:id="@+checklistitem/textSeparator" 
      android:visibility="gone" android:layout_marginLeft="10dp" 
       android:layout_width="240dp" android:layout_height="fill_parent" 
       android:paddingRight="0dp" android:maxLines="2" android:textSize="16dp" 
       android:text="" 
       android:background="#000000" android:textColor="#ffffff" 
       android:layout_centerVertical="true" /> 


      <TextView android:layout_marginLeft="5dp" 
       android:id="@+checklistitem/inspectionvalue" android:visibility="visible" 
       android:layout_width="wrap_content" android:layout_height="wrap_content" 
       android:textColor="#006699" android:text="01" 
       android:layout_alignParentRight="true" android:layout_marginRight="8dp" 
       android:layout_centerVertical="true" /> 
     </TableRow> 
    </TableLayout> 

</RelativeLayout> 

这里就是我曾经适配器我的名单

checklistview.setOnItemClickListener(this); 


     CheckListAdapterForAtt checkAdapter = new CheckListAdapterForAtt(this.getApplicationContext(), checkListRowDataArr, R.layout.checklist_row); 

的代码,但一些如何产品Click听者不为我工作???

+0

相同的问题:定义“不起作用' – njzk2

+0

我有公共无效onItemClick(AdapterView arg0,查看arg1,int arg2,long arg3){}这种方法,但点击该项目的控制不会出现在这? –

回答

1

添加在您需要点击

android:clickable="false" 
android:focusable="false" 

的onclick听众像下面

mList.setOnItemClickListener(new OnItemClickListener() { 

      public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, 
        long arg3) { 

      } 
     }); 
0

尝试这样的XML列布局如下:

listView.setOnItemClickListener(new OnItemClickListener() { 

     private void OnItemSelected() { 

     } 

     public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, 
       long arg3) { 
      if(arg2 == 0) 
      { 

      } 

      if(arg2 == 1) 
      { 

      }