0

リストビューのアイテムをクリックしたときに OnItemClickListener が実行されない理由がわかりません。リストビューとテキストビューの両方に android:focusable="false" を追加しようとしました。助けてくれてありがとう。

     clistArray = new ArrayList<CustomerList>();
     clistDataAdapter = new CustomerListAdapter(this, R.layout.cus_list, clistArray);
 CustView = (ListView)findViewById(R.id.allCustomerList);

     OnItemClickListener cuslistener = new OnItemClickListener (){
        public void onItemClick(AdapterView<?> parent, View view, int position, long id){
                   selectedCustomer = cusdatasource.getCustomer(String.valueOf(id));      
              }
      }

     CustView.setAdapter(clistDataAdapter);
     CustView.setOnItemClickListener(cuslistener);
     CustView.setItemsCanFocus(true);

リストビュー.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="False">

<ListView
    android:id="@+id/allCustomerList"
    android:layout_width="200dp"
    android:layout_height="match_parent"
    android:layout_weight="1" >

</ListView>

cus_list.xml

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

<TextView
    android:id="@+id/clistStop"
    style="@style/WhiteSText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/black"
    android:gravity="center|center_horizontal"
    android:text="123" />

<TextView
    android:id="@+id/clistName"
    style="@style/WhiteSText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/black"
    android:gravity="left"
    android:text="name kkkkk" />

<CheckBox
    android:id="@+id/clistCheck"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/black"
    android:textSize="20dp" />

</LinearLayout>
4

2 に答える 2

0

チェックボックス 1.Focusable = false および 2.FocusableInTouchMode = false のプロパティを設定します。動作します...

于 2013-04-17T04:56:15.197 に答える