Listview Android ImageView未显示且为空
ListView项目中的ImageView没有显示,但是,如果我只是用按钮或其他东西替换ImageView,它会显示得很好 列表项的布局文件Listview Android ImageView未显示且为空,listview,android-studio,layout-inflater,Listview,Android Studio,Layout Inflater,ListView项目中的ImageView没有显示,但是,如果我只是用按钮或其他东西替换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=
<?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" />
是的,ImageView是空的,但它应该有一个边框框,由我的调试工具显示。更重要的是,findViewById为ImageView返回null
,但在被按钮替换时返回有效的按钮引用
也就是说,只有图像视图在此列表视图中被删除。显示其他列表中的图像视图,并显示边框框,即使它们是空的;此ListView中显示的其他内容具有相同的属性集
我没有编写代码来删除它们,而且我根本无法这样做,因为我甚至无法从视图树中获取它们。我没有安装Adblock或其他处理视图的XPose模块。我的系统或手机供应商似乎没有这样做。那么这是谁干的?我想问题就在这里
iv = findViewById(R.id.image);//iv is null
难道不是吗
iv = root.findViewById(R.id.image);
我认为问题就在这里
iv = findViewById(R.id.image);//iv is null
难道不是吗
iv = root.findViewById(R.id.image);
不幸的是,我对此一无所知。