collapse recycler view on new item click

Solutions on MaxInterview for collapse recycler view on new item click by the best coders in the world

showing results for - "collapse recycler view on new item click"
Niclas
16 Jan 2017
1holder.itemView.setOnClickListener(new View.OnClickListener() {
2        @Override
3        public void onClick(View v) {
4            final boolean visibility = holder.details.getVisibility()==View.VISIBLE;
5
6            if (!visibility)
7            {
8                holder.itemView.setActivated(true);
9                holder.details.setVisibility(View.VISIBLE);
10                if (prev_expanded!=-1 && prev_expanded!=position)
11                {
12                    recycler.findViewHolderForLayoutPosition(prev_expanded).itemView.setActivated(false);
13                    recycler.findViewHolderForLayoutPosition(prev_expanded).itemView.findViewById(R.id.cpl_details).setVisibility(View.GONE);
14                }
15                prev_expanded = position;
16            }
17            else
18            {
19                holder.itemView.setActivated(false);
20                holder.details.setVisibility(View.GONE);
21            }
22            TransitionManager.beginDelayedTransition(recycler);              
23        }
24});
25
similar questions
queries leading to this page
collapse recycler view on new item click