Android ImageView 未显示且为空

Android ImageView not displayed and is null

ListView 项内的 ImageView 没有显示,但是如果我只是用 Button 或其他东西替换 ImageView,它显示正常。

列表项的布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="18dp"
    android:gravity="center"
    android:orientation="horizontal"
    android:weightSum="1">

    <ImageView
        android:id="@+id/image"
        android:layout_width="48dp"
        android:layout_height="48dp" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical">

        <TextView
            android:id="@+id/text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="@style/TextAppearance.AppCompat.Medium" />

        <TextView
            android:id="@+id/text2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="@style/TextAppearance.AppCompat.Small" />

    </LinearLayout>

</LinearLayout>

<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@android:color/darker_gray" />

在 Android 工作室看起来不错:

虽然运行时间没有显示:

将"ImageView"替换为"Button"和运行:

膨胀此布局的代码:

@Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        View root = getLayoutInflater().inflate(R.layout.entry_pickblock_list, viewGroup, false);
        Block blk = getItem(i);
        TextView tv = root.findViewById(R.id.text);
        tv.setText(blk.locale_name);
        tv = root.findViewById(R.id.text2);
        tv.setText(getString(R.string.pickblock_entry_detail, blk.id, blk.name));
        ImageView iv = findViewById(R.id.image);//iv is null.
        //iv.setImageDrawable(BlockIcons.get(blk.id));
        return root;
    }

是的,ImageView 是空的,但它应该有一个由我的调试工具显示的边框。更重要的是,findViewById returns null 用于 ImageView,但 returns 一个 valid 按钮引用,当它被 Button 替换时。

也就是说,在thisListView中只去掉了ImageViews
显示其他列表中的 ImageView,即使它们为空也显示边框框;此 ListView 中显示的其他内容具有相同的属性集。

我没有编写代码来删除它们,而且我根本无法这样做,因为我什至无法从视图树中获取它。我没有安装操作视图的 Adblock 或其他 Xposed 模块。我的系统供应商或 phone 似乎没有这样做。那么这是谁干的?

我觉得问题出在这里

iv = findViewById(R.id.image);//iv is null

不应该吗

iv = root.findViewById(R.id.image);