从代码片段中,我记录了一些调试点,发现mImages.size()在不同的地方给出了不同的输出。无论 的值如何mImages.seize(),它总是返回0... public ArrayList<Uri> getImageUris()...对为什么...有任何帮助吗?
public class ImagesAdapter extends RecyclerView.Adapter<ImagesAdapter.ImageViewHolder> {
private ArrayList<Image> mImages;
private ArrayList<Uri> mImagesUri = new ArrayList<>();
private Image mimage;
private Uri uris;
private static final String TAG = "ImagesAdapter";
public ImagesAdapter(ArrayList<Image> images) {
mImages = images;
if (mImages == null)
Log.d(TAG, "ImagesAdapter mImages = null");
}
@Override
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ImageViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.list_pic_update, parent, false));
}
@Override
public void onBindViewHolder(ImageViewHolder holder, final int position) {
holder.bind(mImages.get(position));
holder.cancel.setOnClickListener(view -> {
int rpos = holder.getAdatpterpos();
removeAt(rpos, mImages.get(position).getSource());
Log.d(TAG, "imagesAdapter position = " + position);
});
}
@Override
public int getItemCount() {
Log.d(TAG, "imagesAdapter getItemCount = " + mImages.size());
return mImages.size();
}
public class ImageViewHolder extends RecyclerView.ViewHolder {
protected ImageView imageView;
private ImageButton cancel;
public ImageViewHolder(View itemView) {
super(itemView);
imageView = itemView.findViewById(R.id.news_pic_update_details);
cancel = itemView.findViewById(R.id.cancel_image);
}
潇湘沐
幕布斯7119047
相关分类