我正在使用自定义适配器来显示 ListView,但我的 ListView 表现得非常生涩
我的自定义适配器的代码
class ListAdapter extends BaseAdapter
{
Context context;
ArrayList<T> arr ;
public ListAdapter(Context con,ArrayList<T> arrayList) {
arr = arrayList;
context = con;
}
@Override
public int getCount() {
return arr.size();
}
@Override
public Object getItem(int arg0) {
return arg0;
}
@Override
public long getItemId(int arg0) {
return arg0;
}
@Override
public View getView(int pos, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if(convertView == null ){
viewHolder = new ViewHolder();
convertView = View.inflate( context,R.layout.match_introspection_list_item, null);
viewHolder.teamFlagOneImageView = (ImageView) convertView.findViewById(R.id.imageView1);
viewHolder.teamFlagTwoImageView = (ImageView) convertView.findViewById(R.id.imageView3);
viewHolder.teamOneTextView =(TextView) convertView.findViewById(R.id.textView1);
viewHolder.teamTwoTextView =(TextView) convertView.findViewById(R.id.textView4);
viewHolder.dateTextView =(TextView) convertView.findViewById(R.id.textView2);
viewHolder.placeTextView =(TextView) convertView.findViewById(R.id.textView3);
viewHolder.descTextView = (TextView) convertView.findViewById(R.id.desc);
convertView.setTag(viewHolder);
}else{
viewHolder =(ViewHolder) convertView.getTag();
}
final MatchIntrospectionObjects obj = arr.get(pos);
viewHolder.teamOneTextView.setText(obj.home_team_abbrev);
viewHolder.teamTwoTextView.setText(obj.away_team_abbrev);
viewHolder.descTextView.setText(Html.fromHtml("<b>Description: </b>")+obj.matchdescription);
if(obj.date.equals("")){}else
viewHolder.dateTextView.setText(splitDate(obj.date));
viewHolder.placeTextView.setText(obj.venue);
imageLoader.displayImage(FLAG_BASE_URL+obj.home_flag, viewHolder.teamFlagOneImageView, options, animateFirstListener);
imageLoader.displayImage(FLAG_BASE_URL+obj.away_flag, viewHolder.teamFlagTwoImageView, options, animateFirstListener);
return convertView;
}
}
这是 ListAdpater 的我的代码
我在 Oncreate() 方法中像这样设置 ListAdapter
ListAdapter adapter =new ListAdapter(this,listArray);
mListView.setAdapter(adapter);
这段代码帮助我在我的 ListView 中最小化某种程度的生涩效应。
我正在使用通用图像加载器从 URL 获取图像如果相同的图像想要从相同的 URL 获取不同的单元格,那么 Universal ImageLoader 会再次获取并再次获取,或者它在生命周期中获取一次,然后从缓存中获取可用的图像?