开发者

Notify ListView on layout dynamic change

I have a ListView:

SimpleAdapter adapter = new SimpleAdapter(
                        getApplicationContext(), forecastList,
                 开发者_如何学C       R.layout.weather_list_row, new String[] { "forecast",
                                "precipitation", "temperature" }, new int[] {
                                R.id.forecast, R.id.precipitation,
                                R.id.temperature });
                lv1.setAdapter(adapter);

and I have a "R.layout.weather_list_row" as:

<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>

In the R.layout.weather_list_row I am dynamically changing the src= of the ImageView.

  • Question: How can I notify the ListView, when I change the values in the R.layout.weather_list_row?


try adapter.notifyDataSetChanged();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜