微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

更改回收者视图中所选项目的背景?

如何解决更改回收者视图中所选项目的背景?

解决方案无效,建议在任何条件下均能正常工作的任何解决方案 或其他行为也说明了如何仅将第一项值转换为字符串以进一步用于列表代码视图。

    @Override
    public void onBindViewHolder(@NonNull final ItemViewHolder holder,final int position) {

//                    cvChipsRecycler chipsRecycler = (cvChipsRecycler) listRecyclerItem.get(position);
                    holder.name.setText(listRecyclerItem.get(position));

                    if (selected_position == position) {
                        holder.cvLayout.setBackgroundResource(R.drawable.cv_recycler_layout_clicked_round_background);
                        holder.name.setTextColor(Color.BLACK);
                    }else {
                        holder.cvLayout.setBackgroundResource(R.drawable.abc_round_cornor_grey);
                        holder.name.setTextColor(context.getResources().getColor(R.color.xyz_white,context.getTheme()));
                    }
                   holder.name.setonClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            selected_position = position;
                            try {
                                String stName = (String) holder.name.getText();
                                InputStream is = context.getAssets().open(childName.toLowerCase() + "/" + stName.toLowerCase());
                                int size = is.available();
                                byte[] buffer = new byte[size];
                                is.read(buffer);
                                is.close();
                                String text = new String(buffer);
                                final View rootView = ((cdCodeViewer) context).getwindow().getDecorView().findViewById(android.R.id.content);
                                CodeView cv = (CodeView) rootView.findViewById(R.id.cv_code_viewer);
                                cv.setTheme(CodeViewTheme.DARKULA).fillColor();
                                cv.showCode(text);
                                android.widget.LinearLayout codeViewLayout = (android.widget.LinearLayout) cv.getParent();
                                codeViewLayout.setPadding(8,8,8);
                            } catch (IOException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    });

    }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。