Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
538 views
in Technique[技术] by (71.8m points)

android - recycler view, not scrolling when using an on click listener onto the whole itemview

I want to use an on click listener onto the whole recycler view item. well, I want to use the on click listener when clicking on the item "anywhere" (the whole item). but when the whole item is using an on click listener, as you can see, the click listener is preventing the scrolling. how can i use an on click listener onto the whole item in the recycler, but scrolling should still be possible. i used the systems itemview for the click listener, also a button over the whole item layout, anyway the click listener prevents from scrolling. how to solve this? Thanks! Here the code:

public class ViewHolder extends RecyclerView.ViewHolder {
        public TextView tvBezeichnung;
        public ImageButton buttonSelect;
        public ImageButton buttonUpDown;

        public ViewHolder(View itemView) {
            super(itemView);
            tvBezeichnung = itemView.findViewById(R.id.risftvbezeichnung);
            
            itemview.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    ...
            });

            //also tried buttons/other views over the whole item, on click listener prevents scrolling
        }
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...