1
我有一個ListView有很多「行」。在每一行中,我有一個帶有背景圖像的TextView。當我滾動,行的圖像混合...他們跳轉到另一個滾動的行。 已經嘗試過android:scrollingCache =「false」和android:cacheColorHint =「#00000000」但什麼都沒有。ListView與TextView與背景圖像
圖像被dinamically載入。我的佈局
部分:
<LinearLayout android:id="@+id/QueryList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="3px"
android:layout_below="@id/NavigationTab"
android:layout_above="@id/Query"
android:gravity="top">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:scrollingCache="false"
android:cacheColorHint="#00000000"
android:layout_height="wrap_content">
</ListView>
和我的代碼部分:
public View getView(int position, View convertView, ViewGroup parent) {
ListContent holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.expert_inflate_list, null);
holder = new ListContent();
holder.name = (TextView) convertView.findViewById(R.id.name);
TextView iv = (TextView) convertView.findViewById(R.id.avatar);
holder.avatar = iv;
holder.onLine =(TextView) convertView.findViewById(R.id.online);
convertView.setTag(holder);
} else {
holder = (ListContent) convertView.getTag();
}
String rank = "";
for (int i = 1; i <= ListviewContent.get(position).getRanking(); i++) { rank+=">"; };
holder.name.setText(ListviewContent.get(position).getCompleteName() + " " + rank);
if ( ListviewContent.get(position).getAvatar() != null && !ListviewContent.get(position).getAvatar().equals("null")) {
holder.avatar.setBackgroundDrawable(avatars.get(ListviewContent.get(position).getUserId()));
}
if ( ListviewContent.get(position).getOnline()) {
holder.onLine.setBackgroundDrawable(resources.getDrawable(R.drawable.arrow_on));
} else {
holder.onLine.setBackgroundDrawable(resources.getDrawable(R.drawable.arrow_off));
}
return convertView;
}
「化身」 是可繪製 任何想法的緩存?
謝謝你的迴應......我的英語很差,所以我的解釋不好。該行只檢查圖像的存在。不重要。活動開始時的結果列表是: – 2010-11-15 06:57:29
[Avatar 1]名稱1圖標1 [Avatar 2] Name 2圖標2 [Avatar 3] Name 3圖標3 ... [Avatar N] Name N圖標ñ 當我滾動: [頭像1]名稱1圖標1 [頭像2]名稱2圖標2 [頭像1]名稱3圖標1 ... [頭像N]名稱無圖標ñ 等等...圖像混合和圖標也。我認爲是背景和緩存的問題,但我已停用... 再次感謝。 – 2010-11-15 06:58:49
解決了!你有理由。問題在於缺少「其他」條款。 「false」時發生了什麼:沒有圖標... – 2010-11-15 11:57:27