我正在尝试使用picasso在customadapter中加载多个图像。
public CustomListAdapter(Activity activity,String[] planet,String[] images_url){
super(activity,R.layout.simplerow,planet);
this.activity=activity;
this.planet=planet;
this.images_url=images_url;
}
public View getView(int position,View view,ViewGroup parent){
LayoutInflater inflater=activity.getLayoutInflater();
View rowView=inflater.inflate(R.layout.simplerow, null, true);
TextView txtName=(TextView)rowView.findViewById(R.id.rowTextView);
ImageView imageView=(ImageView)rowView.findViewById(R.id.img2);
txtName.setText(planet[position]);
Picasso.with(activity).load(images_url[position]).into(imageView);
return rowView;
}
以下是我打电话的方式。它工作正常,显示行星名称列表,但没有图像。
String[] planets = new String[] { "Mercury", "Venus", "Earth"};
String[] images_url = new String[]{
"http://i.imgur.com/DvpvklR.png","http://i.imgur.com/XjpMiHR.png","http://i.imgur.com/9fGn1PX.png%22"
};
String string_array_dat[]=new String[hold_data.size()];
string_array_dat=hold_data.toArray(string_array_dat);
// CustomListAdapter
CustomListAdapter customadpt = new CustomListAdapter(activity,planets,images_url);
ListView lstview=(ListView)findViewById(R.id.mainListView);
lstview.setAdapter(customadpt);
我的logcat显示以下错误:
10-07 02:16:17.599 30112-30112/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
10-07 02:16:17.599 30112-30112/? E/android.os.Debug﹕ failed to load memtrack module: -2
10-07 02:16:31.429 1161-1295/system_process E/SoundPool﹕ error loading /system/media/audio/ui/Effect_Tick.ogg
答案 0 :(得分:0)
我的问题的解决方案是更改以下代码:
View rowView=inflater.inflate(R.layout.simplerow,parent,false);