在我的应用程序中,我正在使用UrlImageViewHelper库。在运行时,该应用程序将从服务器和超过 300 个相关图像中获取一个 xml 文件。我面临与滚动速度有关的问题。当我更快地向下滚动时,它会卡住,运行速度很慢。我试过不下载图像,它工作得很好。然后我对图书馆的图像缩放代码进行了一些更改,但没有帮助。即使我尝试了该库中称为“时髦的快速加载”的方法loadUrlDrawable() ,不幸的是,仍然没有成功。
这是我的应用程序的外观:
适配器的xml文件很简单,这里是JAVA代码:
public class MyAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
public MyAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
activity = a;
data=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.list_row, null);
TextView title = (TextView)vi.findViewById(R.id.title); // title
TextView artist = (TextView)vi.findViewById(R.id.artist); // artist name
TextView duration = (TextView)vi.findViewById(R.id.duration); // duration
ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image
HashMap<String, String> song = new HashMap<String, String>();
song = data.get(position);
// Setting all values in listview
title.setText(song.get(CustomizedListView.KEY_TITLE));
artist.setText(song.get(CustomizedListView.KEY_ARTIST));
duration.setText(song.get(CustomizedListView.KEY_DURATION));
UrlImageViewCallback imgCallback = new UrlImageViewCallback() {
@Override
public void onLoaded(ImageView imageView, Drawable loadedDrawable,
String url, boolean loadedFromCache) {
thumb_image.setImageDrawable(loadedDrawable);
}
};
UrlImageViewHelper.loadUrlDrawable(thumb_image.getContext(), Const.URL_SMALL_IMAGES + restoran.getId() + "/1_m.jpg", imgCallback);
}
}
我究竟做错了什么?任何帮助将不胜感激。