2017-10-07 1 views
-2

quand je clique listview article qui contient textview et case à cocher, setOnItemClickListener ne fonctionne pasandroid ListView contient case setonItemclick ne fonctionne pas

ceci est mon code java

android listview contient case setonItemclick ne fonctionne pas

etiket_list.setOnItemClickListener(new AdapterView.OnItemClickListener() { 

      @Override 
      public void onItemClick(AdapterView<?> parent, View view, int position, 
            long id) { 
       final Database dbD = new Database(context); // Db bağlantısı oluşturuyoruz. İlk seferde database oluşturulur. 
       Tags = dbD.Etiketler(); 
       final int temp_id = Integer.valueOf(Tags.get(db.Etiketler().size()-position-1).get("tag_id")); 
       final int pozisyon=db.Etiketler().size()-position-1; 
       if (syac % 2 == 0) { 
        val_tag=val_tag+Tags.get(pozisyon).get("tag")+" "; 
        tag.setText(val_tag); 
        syac++; 
       } else { 
        String newTags = tag.getText().toString().replaceAll(Tags.get(pozisyon).get("tag"),""); 
        syac++; 
        tag.setText(newTags); 
       } 

      } 
     });   

Voici ma liste élément Code XML:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:focusable="false" 
    android:descendantFocusability="blocksDescendants" 
    android:weightSum="1"> 

    <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.09" 
     android:background="#f8f8f8" 
     android:descendantFocusability="blocksDescendants" 
     android:id="@+id/item_li_frame"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:text="list_item_etiket2" 
      android:id="@+id/list_item_etiket2" 
      android:layout_gravity="left|center_vertical" 
      android:layout_marginLeft="16dp" 
      android:layout_marginRight="6dp" 
      android:textColor="#4a4a4a" 
      android:textStyle="bold" 
      android:focusableInTouchMode="false" 
      android:focusable="false" 
      android:textSize="16dp" /> 

     <CheckBox 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/etiket_checkBox" 
      android:layout_gravity="right|center_vertical" 
      android:focusable="false" 
      android:focusableInTouchMode="false" 
      android:layout_marginRight="16dp" /> 
    </FrameLayout> 
</LinearLayout> 

Android contient listview case setonItemclick ne fonctionne pas

Répondre

0

Vous avez placé un TextView et CheckBox dans un FrameLayout de sorte que le checkBox se trouve au-dessus du textView et consume les événements tactiles. Placez-les dans une autre disposition, par exemple LinearLayout