我的viewpager使用带有回收站视图的相同片段来显示根据viewpager的位置从Internet下载的列表。当一切都是首次启动时,一切都正确加载但是当我滚动回收器视图时,信息从第二页加载。
我的回收器适配器的构造函数
//Constructor
public FeedAdapter(List<Feed> feed, Context ctx, Activity activity){
mFeed = feed;
context = ctx;
try{
mListener = (OnAdapterInteractionListener) activity;
}catch (ClassCastException e){
throw new ClassCastException(activity.toString() + " must implement OnAdapterInteraction");
}
}
和我的bindview
@Override
public void onBindViewHolder(final FeedAdapter.ViewHolder holder, final int i) {
holder.mItem = mFeed.get(i);
holder.mTitle = holder.mItem.mTitle;
holder.mImageLink = holder.mItem.mImageLink;
holder.mDescription = holder.mItem.mDescription;
//set default image and title text to show if image doesn't exist or hasn't downloaded yet
holder.ivCardImage.setImageResource(R.drawable.rhaa);
holder.tvTitle.setVisibility(View.VISIBLE);
holder.tvTitle.setText(holder.mTitle);
holder.tvDescription.setText(holder.mDescription);
...}
和来自片段的调用:
mAdapter = new FeedAdapter(feed, context, activity);
mRecyclerView.setAdapter(mAdapter);
Feed是一个自定义类,用于存储下载项目的所有信息。在设置viewpager并从导航器中选择选项卡之前一切正常,所以我知道问题在于viewpager我不知道如何修复它。