2010-08-18 59 views
0

後不updatet我使用基於行的佈局列表中的元素有一個列表活動:圖像變化

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

我填了SimpleAdapter名單,超過提供數據此列表:

List<HashMap<String, String> > data; 

我最初用一些字符串和默認圖像加載數據。主要圖像稍後加載。將圖像保存爲資源ID

Integer.toString(R.drawable.check) 

現在的問題: 雖然我最初投入列表中的圖像是正確加載,更新的項目不直接改變其外觀。他們必須離開可視區域(在滾動的視圖中,我必須滾動,直到它們離開窗戶,如果我將它們向後滾動,它們會改變它們的外觀)。這個問題不僅涉及圖像,還涉及文本(我不會在我的應用程序中更新)。

我是否必須使用ArrayAdapter而不是SimpleAdapter來自動更新工作?

感謝您的任何形式的提示和詢問,如果我沒有讓自己清楚

回答

1

一個SimpleAdapter

一個簡單的適配器靜態數據映射到的意見

從而如果您的數據將來發生更改,則應使用ArrayAdapter。在後者中,在更新後的數據調用

mArrayAdapter.notifyDataSetChanged(); 

和圖像應當自動更新

PS。 Same question

1

SimpleAdapter還支持方法notifyDataSetChanged(),所以沒有必要使用一個ArrayAdapter