A
A
AlexeyID2018-07-16 20:33:48
Android
AlexeyID, 2018-07-16 20:33:48

How to make the ripple effect work in RecyclerView?

Tell me how to make the ripple effect work in RecyclerView?
When setting the listener setOnClickListener to the ViewHolder , the effect stops working and is it correct to set the listener in general this way?

class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
    TextView text;

 ViewHolder(View itemView) {
            super(itemView);
            text= itemView.findViewById(R.id.text);
            text.setOnClickListener(this);
        }

   public void onClick(View v) {
   }
}

Doesn't work with setOnClickListener
android:foreground="?android:attr/selectableItemBackground"
   android:clickable="true"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
davidnum95, 2018-07-17
@AlexeyID

android:background="?android:attr/selectableItemBackground"

add to item container

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question