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

问题描述 投票:0回答:1

在我的应用程序中,我使用 UrlImageViewHelper 库。在运行时,应用程序将从服务器获取一个 xml 文件以及超过 300 个相关图像。我面临与滚动速度相关的问题。当我更快地向下滚动时,它会卡住,工作速度非常慢。我尝试不下载图像,效果很好。然后我对库的图像缩放代码做了一些更改,但没有帮助。即使我尝试了该库中称为“时髦的快速加载”的方法 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);
 }
}

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

android imageview baseadapter
1个回答
0
投票

能给我 XML 文件吗?

© www.soinside.com 2019 - 2024. All rights reserved.