ListView does not respond with background effects when clicking on item

0

ListView code

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

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="#000000"
    android:dividerHeight="2dp"
    android:id="@+id/list_notify"
    >
</ListView>
</FrameLayout

code of the items that are contained in the ListView

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout  xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/list_item_selector">

<ImageView
    android:id="@+id/imageView_lista_notify"
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:layout_margin="4dp"
    android:src="@drawable/ic_menu_gallery" />

<TextView
    android:id="@+id/texto_hora_list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:text="TextView"
    app:layout_constraintLeft_toRightOf="@+id/imageView_lista_notify"
    android:layout_marginLeft="8dp"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginTop="4dp" />

<TextView
    android:id="@+id/texto_notificacao_list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:text="TextView"
    app:layout_constraintLeft_toRightOf="@+id/imageView_lista_notify"
    android:layout_marginLeft="8dp"
    app:layout_constraintTop_toBottomOf="@+id/texto_hora_list" />



<ImageButton
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:src="@android:drawable/ic_delete"
    android:layout_marginRight="8dp"
    app:layout_constraintRight_toRightOf="parent"
    android:id="@+id/imageButton"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginTop="10dp" />
 </android.support.constraint.ConstraintLayout>
    
asked by anonymous 18.05.2017 / 18:44

1 answer

0

Try changing the value of the "android: background" attribute of your ConstraintLayout to this:

android:background="?attr/selectableItemBackground"

In RecyclerViews it enables the click effect, I believe it should work for ListView too.

    
18.05.2017 / 18:50