使用 recyclerview 的问题

Issue working with a recyclerview

我在 android 应用程序上使用回收站视图时遇到问题。 一切正常,直到我向回收站视图添加 4/5 行。并且应用程序崩溃。

这是recycler视图的模型,在应用程序中我在文本视图中动态添加图像和文本。

<ImageView
    android:id="@+id/imageIDEntryList"
    android:layout_width="90dp"
    android:layout_height="90dp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:srcCompat="@drawable/ic_image_grey_24dp" />

<TextView
    android:id="@+id/entryNameRecycler"
    android:layout_width="0dp"
    android:layout_height="90dp"
    android:gravity="left|center"
    android:text="TextView"
    android:textColor="@android:color/black"
    android:textSize="35dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toEndOf="@+id/imageIDEntryList"
    app:layout_constraintTop_toTopOf="parent" />

我正在使用 jpeg 格式将图像保存在回收站视图中。 是图片尺寸过大导致的崩溃吗? 我还使用了一个库 (imagepicker) 来管理图像并放入回收器视图的行中。

这是问题所在:

android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable

这是我将图像添加到 imageView 的地方

if(requestCode == Keys.IMAGE_INTENT_REQUEST_CODE && resultCode == RESULT_OK) {
        final Uri imageUri = Uri.fromFile(new File(ImagePicker.getFirstImageOrNull(data).getPath()));
        try {
            bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
        }catch(IOException e){
            e.printStackTrace();
        }
        imageView.setImageBitmap(bitmap);
    }

崩溃是怎么造成的?

大部分使用 Picasso or Glide 更新 RecyclerView 中的图像。这些库是开源的,比使用位图更有效。

使用Picasso,加载ImageView就像

一样简单

Picasso.get().load(yourUri).into(imageView);
它还将 运行 有效地使您的回收站视图平滑滚动。