实际上我的问题和这个人的一样。但我不知道如何解决它。这是我的 listview xml 文件。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:background="#CCCCCC"
android:id="@+id/tabs">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#CCCCCC"
android:textSize="20sp"
android:textColor="#000000"
android:text="@string/NewTask"
android:id="@+id/tab1"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CCCCCC"
android:layout_weight="1"
android:textSize="20sp"
android:textColor="#000000"
android:text="@string/Friends"
android:id="@+id/tab2"
/>
<Button
android:layout_width="fill_parent"
android:background="#CCCCCC"
android:layout_height="wrap_content"
android:textColor="#000000"
android:layout_weight="1"
android:text="@string/AddPeople"
android:textSize="20sp"
android:id="@+id/tab3"
/>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#000000"
android:layout_below="@+id/tabs"
/>
</RelativeLayout>
我正在尝试从onpostExecute
我的AsyncTask class
. 这是我的列表活动的功能。
public void SetImage(Bitmap bmp,int index)
{
View v = this.ls.getChildAt(index);
ImageView img = (ImageView)v.findViewById(R.id.tasks_userimg);
img.setImageBitmap(bmp);
}
这个 bmp 是asynctask
类中下载的位图,ls
是列表视图,是列表视图index
中项目的索引。当 postexecute 运行时,我使用参数调用此函数以更新列表视图项目图像。
问题与我在链接中提到的完全相同,即当我滚动它时出现错误。但他通过更改列表视图的布局宽度解决了问题,但它在这里不起作用。