我有一个 ListView:
SimpleAdapter adapter = new SimpleAdapter(
getApplicationContext(), forecastList,
R.layout.weather_list_row, new String[] { "forecast",
"precipitation", "temperature" }, new int[] {
R.id.forecast, R.id.precipitation,
R.id.temperature });
lv1.setAdapter(adapter);
我有一个“R.layout.weather_list_row”:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="4dip" android:paddingBottom="6dip"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="@+id/forecast" android:layout_width="150dip"
android:layout_height="wrap_content" android:textColor="#000000" />
<LinearLayout android:layout_height="wrap_content"
android:layout_weight="1" android:layout_width="50dip">
<TextView android:id="@+id/precipitation"
android:layout_width="wrap_content" android:textColor="#00357A"
android:layout_height="wrap_content" />
<ImageView android:layout_height="wrap_content" android:id="@+id/weather_status1"
android:layout_width="wrap_content" />
</LinearLayout>
<LinearLayout android:layout_height="wrap_content"
android:layout_weight="1" android:layout_width="50dip">
<TextView android:id="@+id/temperature" android:layout_width="wrap_content"
android:textColor="#00357A" android:layout_height="wrap_content" />
<ImageView android:layout_height="wrap_content" android:id="@+id/weather_status2"
android:layout_width="wrap_content" />
</LinearLayout>
</LinearLayout>
在 R.layout.weather_list_row 中,我正在动态更改 ImageView 的 src=。
- 问题:当我更改 R.layout.weather_list_row 中的值?
最佳答案
试试 adapter.notifyDataSetChanged();
关于android - 通知 ListView 布局动态变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7683677/