Android ImageView 不会在带有 ViewHolder 的 CustomList 上加载

Android ImageView won't load on CustomList with ViewHolder

我有一个自定义列表视图,最近升级为使用 View Holder。现在项目工作正常,但是两个图像视图中的图像没有显示在屏幕上。

出现这两个黑色图标"transparent",但如果我单击它们,它们就会起作用。

这是布局:

  <?xml version="1.0" encoding="UTF-8"?>

    <LinearLayout xmlns:tools="http://schemas.android.com/tools"
        android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:orientation="vertical"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">


    <RelativeLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/imgInfo"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentTop="true"
                android:layout_marginTop="12dp"
                android:layout_weight="0.04"
                android:visibility="visible"
                app:srcCompat="@drawable/details64" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_toEndOf="@+id/imgInfo"
                android:layout_toLeftOf="@+id/imgEdit"
                android:layout_toRightOf="@+id/imgInfo"
                android:layout_weight="0.24"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/txtChamado"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:textAlignment="center"
                    android:textColor="@android:color/background_dark"
                    android:textSize="25sp" />

                <TextView
                    android:id="@+id/txtSolicitante"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textAlignment="center"
                    android:textColor="@android:color/background_dark"
                    android:textSize="15sp" />

                <TextView
                    android:id="@+id/txtItemDeCatalogo"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textAlignment="center"
                    android:textColor="@android:color/background_dark"
                    android:textSize="15sp" />
            </LinearLayout>

            <ImageView
                android:id="@+id/imgEdit"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_marginTop="12dp"
                android:layout_weight="0.03"
                android:contentDescription=""
                app:srcCompat="@drawable/pencil64" />
        </LinearLayout>


    </RelativeLayout>

</LinearLayout>

这是代码片段:

 @Override
    public View getView(final int position, View view, final ViewGroup parent) {

        View convertView;
        ViewHolder holder;

        if (view == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.customized_list_view, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else{
            convertView = view;
            holder = (ViewHolder) convertView.getTag();
        }

        //  Object declaration
        final Sette setteData = getItem(position);

        //region Put the Tasks values to the textviews
        // Get me two strings, one with the older value and one with the newest
            String oldChamado = holder.txtChamado.getText().toString();
            String newChamado = setteData.getChamado();
            // Do not repeat the string in the textview
            if (!(oldChamado.equals(newChamado))) {
                holder.txtChamado.setText(newChamado);
            }
     //region Click Listener for the button that leads to Approvals Activity
        if (!aBoolean) {
            holder.imgEdit.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    chamadoClicked = setteData.getChamado();
                    solicitanteClicked = setteData.getSolicitante();
                    itemDeCatalogoClicked = setteData.getItemDeCatalogo();
                    id = setteData.getId();

                    Intent intent = new Intent(context.getApplicationContext(), ApprovalsActivity.class);
                    intent.putExtra("Id", id);
                    intent.putExtra("chamadoClicked", chamadoClicked);
                    intent.putExtra("solicitanteClicked", solicitanteClicked);
                    intent.putExtra("itemDeCatalogoClicked", itemDeCatalogoClicked);
                    context.startActivity(intent);
                }
            });
        }
        //endregion
 return convertView;
    }// END METHOD

ViewHolder(我从互联网示例中得到的):

  public class ViewHolder {
    TextView txtChamado;
    TextView txtSolicitante;
    TextView txtItemDeCatalogo;
    ImageView imgInfo, imgEdit;
    Typeface bebasKai;
    Typeface london;

    public ViewHolder(View view){
        bebasKai = Typeface.createFromAsset(context.getAssets(), "fonts/bebaskai.otf");
        london = Typeface.createFromAsset(context.getAssets(), "fonts/london.ttf");
        txtChamado = (TextView) view.findViewById(R.id.txtChamado);
        txtChamado.setTypeface(bebasKai);
        txtSolicitante = (TextView) view.findViewById(R.id.txtSolicitante);
        txtSolicitante.setTypeface(london);
        txtItemDeCatalogo = (TextView) view.findViewById(R.id.txtItemDeCatalogo);
        txtItemDeCatalogo.setTypeface(london);
        imgEdit = (ImageView) view.findViewById(R.id.imgEdit);
        imgInfo = (ImageView) view.findViewById(R.id.imgInfo);
    }
}

我尝试清理、重建、再次从 BitBucket 下载项目,在我的 phone 上从头开始重新安装应用程序,使 cache/restart 失效并检查代码。

我是不是遗漏了什么明显的东西?

**编辑:**谢谢 SaNtoRiaN,我知道我错过了一些简单的事情。

ImageView 中的 app:srcCompat 属性更改为 android:src 以正确查看图像。要了解更多差异,请查看 答案。