您好,我正在为 ArrayAdapter 使用动画。我想在加载缩略图时对其进行动画处理...但是,每次加载列表的任何缩略图时,都会为数组适配器的每个项目启动动画。结果,每个缩略图的动画被启动 5 次。加载任何项目时,我必须做些什么来防止启动动画?
public View getView(int position, View item, ViewGroup parent){
ViewHolder holder;
Video video = mVideoList.get(position);
if(item == null)
{
item = mInflater.inflate(R.layout.adapter_recommended_videos, null);
holder = new ViewHolder();
holder.title = (TextView)item.findViewById(R.id.adapter_recommended_videos_textview);
holder.thumb = (ImageView)item.findViewById(R.id.adapter_recommended_videos_imageview);
holder.title.setTypeface(
Typeface.createFromAsset(mContext.getAssets(), "roboto_medium.ttf"));
item.setTag(holder);
}
else
{
holder = (ViewHolder) item.getTag();
}
holder.title.setText(video.getTitle());
ImageView iv = holder.thumb;
if (video.getThumb() != null) {
if(!mAnimationFlags.get(position)){
iv.startAnimation(mAnimation);
mAnimationFlags.set(position, true);
}
holder.thumb.setImageBitmap(video.getThumb());
} else {
holder.thumb.setImageResource(R.drawable.dummy_video_thumbnail);
}
return(item);
}
static class ViewHolder {
TextView title;
ImageView thumb;
}