我想显示像Instagram这样的供稿,为此我使用了2种布局。 在该适配器中使用回收视图,我使用多页图像或多张图像检查视图类型,对于多图像我正在使用视图寻呼机。
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view;
switch (viewType) {
case ModelUser.VIEW_PAGER:
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.feed_multi_photo, parent, false);
return new TextTypeViewHolder(view);
case ModelUser.IMAGE_TYPE:
view = LayoutInflater.from(parent.getContext()).inflate(R.layout.feed_photo, parent, false);
return new ImageTypeViewHolder(view);
}
return null;
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int listPosition) {
ModelUser object = dataSet.get(listPosition);
if (object != null) {
switch (object.type1) {
case ModelUser.VIEW_PAGER:
final SliderPagerAdapter sliderPagerAdapter = new SliderPagerAdapter((Activity) mContext, slider_image_list);
((TextTypeViewHolder) holder).mvViewPager.setAdapter(sliderPagerAdapter);
((TextTypeViewHolder) holder).mvViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
addBottomDots(position, ((TextTypeViewHolder) holder).ll_dots);
page = position;
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
在设置我正在使用的适配器数据时
MultiViewTypeAdapter feedMainAdapter = new MultiViewTypeAdapter(feed_list,imagelist,context);
RecylerFeed.setAdapter(feedMainAdapter);
feed_list用于单个图像,imagelist用于多图像,所以我的问题在imagelist中,我正在获取每个图像的列表,如何区分特定用户的图像?
答案 0 :(得分:0)
在
中添加RecyclereViewfeed_multi_photo
在onBindViewHolder
内
switch (object.type1) {
case ModelUser.VIEW_PAGER:
//Impement Nested RecyclerAdapter of Multiple Image using imagelist
InnerRecyclerviewAdapter adapter=new InnerRecyclerviewAdapter(context,imagelist);
holder.recyclerView.setAdapter(adapter);
holder.recyclerView.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
recyclerView.setLayoutManager(layoutManager);
答案 1 :(得分:0)
我的问题是在图像列表中,我正在获取每个图像的列表
因为在包含所有用户图像的slider_image_list
中传递了SliderPagerAdapter
。
如何区分特定用户的图像?
从slider_image_list
创建新的用户特定图像列表,然后再传递给ViewPager:
case ModelUser.VIEW_PAGER:
//Create new List of images for current user from `slider_image_list`
ArrayList<> currentUserImages=new ArrayList<>();
final SliderPagerAdapter sliderPagerAdapter =
new SliderPagerAdapter((Activity) mContext, currentUserImages);
....
break;