I have a list-activity using a row-based layout for elements of the list:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/exerciseText" android:textSize="40sp" android:layout_weight="1开发者_如何学运维" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<ImageView android:id="@+id/solutionImage" android:scaleType="center" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
</LinearLayout>
I fill the list with a SimpleAdapter and provide the data over this List:
List<HashMap<String, String> > data;
I initially load the data with some strings and default image. The main images are loaded later. The images are saved as resource ids
Integer.toString(R.drawable.check)
Now the problem: While the images I initially put into the list are loading properly, updated items don't change their appearance directly. They have to be out of the viewable area(In the scrolled view I have to scroll until they are out of the window. If I scroll them back they changed their appearance). This problem does not only concern to images but also on texts(which I don't update in my App).
Do I have to use an ArrayAdapter rather than a SimpleAdapter to get automatically updating work?
Thanks for tips in any kind and please ask if I didn't make myself clear
A SimpleAdapter is
An easy adapter to map static data to views
thus if your data is subjected to changes in the future, you should use an ArrayAdapter. In the latter, after updating the data call
mArrayAdapter.notifyDataSetChanged();
and the images should update automatically
PS. Same question
SimpleAdapter
also supports the method notifyDataSetChanged()
, so no need to use a ArrayAdapter
精彩评论