Уведомить ListView о динамическом изменении макета - PullRequest
1 голос
/ 07 октября 2011

У меня есть 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 Я динамически изменяю src = из ImageView .

  • Вопрос: Как я могу уведомить ListView, когда я изменяю значения в R.layout.weather_list_row?

1 Ответ

2 голосов
/ 07 октября 2011

попробуй adapter.notifyDataSetChanged();

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...