滚动时添加Android RecyclerView错误视图

时间:2016-03-23 11:53:03

标签: android android-layout android-recyclerview

H1,我使用SliderLayout作为我的物品。 这是我将代码添加到SliderLayout的代码:

final ModelTimeline data = timelineList.get(position);

... other case...

        case TYPE_ATTACHMENTS:
final TimeLineHolderAttachments holder_attachments = (TimeLineHolderAttachments) viewHolder;
                        ....
                        List<String> list_all = data.getAttachments();

                        if (list_all.size() > 0) {
                            for (final String url : list_all) {


                TextSliderView textSliderView = new TextSliderView(mContext);
                            textSliderView
                                    .image(url)
                                    .setScaleType(BaseSliderView.ScaleType.CenterCrop)
                                    .setOnSliderClickListener(new BaseSliderView.OnSliderClickListener() {
                                        @Override
                                        public void onSliderClick(BaseSliderView slider) {
                                            Intent imageViewer = new Intent(mContext, ImageViewer.class);
                                            imageViewer.putExtra("image_url", url);
                                            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                                                ActivityOptions options = ActivityOptions
                                                        .makeSceneTransitionAnimation(((Activity) mContext), holder_attachments.mDemoSlider, "imageviewer");
                                                mContext.startActivity(imageViewer, options.toBundle());
                                            } else {
                                                mContext.startActivity(imageViewer);
                                            }
                                        }
                                    });

                            holder_all.mDemoSlider.addSlider(textSliderView);
                        }
                        holder_all.mDemoSlider.stopAutoCycle();
                    } else {
                        holder_all.mDemoSlider.removeAllSliders();
                    }
                    ...
                    break;
    ...

当我在这个SliderLayout中滚动我的RecyclerView时,会从其他项目中添加错误的图像。怎么解决这个问题?

0 个答案:

没有答案