【发布时间】:2010-11-12 11:44:27
【问题描述】:
我有一个包含很多“行”的 ListView。在每一行中,我都有一个带有背景图像的 TextView。当我滚动时,行的图像混合在一起......它们随着滚动跳到另一行。 在尝试过 android:scrollingCache="false" 和 android:cacheColorHint="#00000000" 但没有。
图像被动态加载。
我的部分布局:
<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;
}
"avatars" 是 Drawables 的缓存 有什么想法吗?
【问题讨论】: