使用BaseAdapter和ImageView Helper下载图像时慢速滚动

时间:2012-12-25 05:11:57

标签: android imageview baseadapter

在我的应用中,我正在使用UrlImageViewHelper库。在运行时,应用程序将从服务器和相关图像中获取超过300的xml文件。我面临与滚动速度相关的问题。当我向下滚动速度更快时,它会卡住,效果非常慢。我尝试没有下载图像,它工作得很好。然后我对图书馆的图像缩放代码进行了一些更改,但它没有任何帮助。甚至我尝试了方法 loadUrlDrawable(),称为"时髦的快速加载"不幸的是,从那个图书馆仍然没有成功。

以下是我的应用的外观:

enter image description here

适配器的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);
 }
}

我做错了什么? 任何帮助将非常感激。

0 个答案:

没有答案