L
L
leha782016-09-19 13:15:42
Android
leha78, 2016-09-19 13:15:42

How to correctly click on an item?

e1a20f95e23c4b3b87f2946bbb56f57d.jpg
When you click on the text, the DetailActivity does not start, but when you click on the block itself, in an area where there is no text, it goes, you need to make the block itself clickable, and as if clicked through the text. How can you achieve?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Elysey, 2016-09-19
@Elysey

As one of the options:
In the adapter:

@Override
    public void onBindViewHolder(final ViewHolder holder, int position) {
        holder.view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                
            }
        });
    }

public class ViewHolder extends RecyclerView.ViewHolder {
        public final View view;

        public ViewHolder(View v) {
            super(v);
            view = v;
        }
    }

A
Artem Gapchenko, 2016-09-20
@artemgapchenko

Add the following to your item's root ViewGroup:
android:descendantFocusability="blocksDescendants"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question