Androidで画像の遅延読み込みを実装しようとしています。ここでこの優れたチュートリアルに従いました: http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/
問題は、エミュレーターで完全に正常に動作することです。エミュレーターでは画像が読み込まれますが、実際のデバイスではデフォルトの画像が表示されるだけです。
私は 6 台の Android デバイスでテストしましたが、うまくいきませんでしたが、エミュレータでは完全にロードされました。
私がどこで間違っているのかについてのアイデアはありますか?
よろしくお願いします!
編集: XML 解析ではなく JSON 解析を使用するようにコードを変更しました。
私のレイジーアダプタークラス:
public class LazyAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader;
public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
activity = a;
data=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
imageLoader=new ImageLoader(activity.getApplicationContext());
// Toast.makeText(a, "here too", 500).show();
}
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
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("msg"));
imageLoader.DisplayImage(song.get("thumb"), thumb_image);
return vi;
}
}