我显示职位就像facebook,并在每个职位有一个图像滑块与多个图像,在我的清单第一项是不同的,然后其他项目,所以我是使用多相RecyclerView,在这里我做了什么,请参阅我的代码,水平RecyclerView里面垂直recyclerview不工作,onCreateViewHolder从来没有打电话
if (commentList.get(position).getAttachment() != null && !commentList.get(position).getAttachment().equals(""))
{
List<String> imageUrl = new ArrayList<>();
imageUrl.add(commentList.get(position).getAttachment());
holder.getImageSliderCommentRecycler().setAdapter(new ImageSliderAdapter(context, imageUrl, new ImageSlideItemListener()
{
@Override
public void imageClicked(int position)
{
List<String> imageUrl = new ArrayList<>();
imageUrl.add(commentList.get(holder.getAdapterPosition()-1).getAttachment());
listener.showImage(imageUrl, position);
}
}));
holder.getImageSliderCommentRecycler().setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
}
else holder.getImageSliderCommentRecycler().setVisibility(View.GONE);
如果条件执行,但imageSliderAdapter永远不会调用oncreateViewHolder或其他任何东西...这里是XML代码,请参阅,
<RelativeLayout
android:id="@+id/post_photo_relative_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/comment_textview"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="35dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/about_doctor_fragment_doctor_photos_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"/>
</RelativeLayout>
这里是我的adapterV iewHolder ...
public class CommentViewHolder extends RecyclerView.ViewHolder
{
private ImageView commentProfileImage;
private TextView commentName;
private TextView commentSpeciality;
private ImageView commentDeleteIcon;
private Button bookAppointmentButton;
private TextView commentDescription;
private TextView commentDateTime;
private ImageView commentLikeIcon;
private TextView commentLikeCounter;
private Button replyButton;
private RecyclerView replyRecyclerView;
private RecyclerView imageSliderCommentRecycler;
public CommentViewHolder(View itemView)
{
super(itemView);
commentProfileImage = (ImageView) itemView.findViewById(R.id.photo_imageview);
commentName = (TextView) itemView.findViewById(R.id.user_name_textview);
commentSpeciality = (TextView) itemView.findViewById(R.id.user_speciality_textview);
commentDeleteIcon = (ImageView) itemView.findViewById(R.id.delete_comment_imageview);
bookAppointmentButton = (Button) itemView.findViewById(R.id.book_appointment_button);
commentDescription = (TextView) itemView.findViewById(R.id.comment_textview);
commentDateTime = (TextView) itemView.findViewById(R.id.comment_time_textview);
commentLikeIcon = (ImageView) itemView.findViewById(R.id.like_imageview);
commentLikeCounter = (TextView) itemView.findViewById(R.id.likes_count_textview);
replyButton = (Button) itemView.findViewById(R.id.reply_button);
replyRecyclerView = (RecyclerView) itemView.findViewById(R.id.replies_recyclerview);
imageSliderCommentRecycler = (RecyclerView) itemView.findViewById(R.id.about_doctor_fragment_doctor_photos_fragment);
}
public ImageView getCommentProfileImage()
{
return commentProfileImage;
}
public TextView getCommentName()
{
return commentName;
}
public TextView getCommentSpeciality()
{
return commentSpeciality;
}
public ImageView getCommentDeleteIcon()
{
return commentDeleteIcon;
}
public Button getBookAppointmentButton()
{
return bookAppointmentButton;
}
public TextView getCommentDescription()
{
return commentDescription;
}
public TextView getCommentDateTime()
{
return commentDateTime;
}
public ImageView getCommentLikeIcon()
{
return commentLikeIcon;
}
public TextView getCommentLikeCounter()
{
return commentLikeCounter;
}
public Button getReplyButton()
{
return replyButton;
}
public RecyclerView getReplyRecyclerView()
{
return replyRecyclerView;
}
public RecyclerView getImageSliderCommentRecycler()
{
return imageSliderCommentRecycler;
}
}
代码是非常复杂的,因此我张贴只是块,因为一切在一天前工作正常....这个图像滑块我刚才说,在那个时候它工作正常,但现在不是......
任何帮助将感激...在此先感谢
我已经经历了几乎所有的解决方案,但没有为我工作...所以请至少要求在编辑或提交作为重复之前一次.... – Najam
添加您的适配器/持有人代码和你的活动请 –
@JonathanAste谢谢你的回复.....完整的代码太冗长太粘贴在这里....我设置适配器在第一个代码块.... – Najam