如何實現此目的?我一直在尋找,我迷路了。如果有人能夠啓發我,那會很棒。這是我目前定製adapter
:在自定義listvew上實現通用圖像加載器Android
public class CustomListAdapter extends ArrayAdapter<String>
{
private final Activity context;
private final String[] itemname;
private final String[] imageUrls;
public CustomListAdapter(Activity context, String[] itemname, String[] imageUrls) {
super(context, R.layout.mylist, itemname);
this.context = context;
this.itemname = itemname;
this.imageUrls = imageUrls;
//ImageLoader imageLoader = new ImageLoader(activity.getApplicationContext());
}
public View getView(int position,View view,ViewGroup parent) {
LayoutInflater inflater=context.getLayoutInflater();
View rowView=inflater.inflate(R.layout.mylist, null,true);
TextView txtTitle = (TextView) rowView.findViewById(R.id.item);
ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
TextView extratxt = (TextView) rowView.findViewById(R.id.textView1);
txtTitle.setText(itemname[position]);
//imageLoader.displayImage(imageUrls[position], imageView, null);
extratxt.setText("Description "+itemname[position]);
return rowView;
};
}
注意上面的代碼中有一些錯誤。首先,在activity.getApplicationContext()
:我不知道爲什麼。對於第二個,imageLoader說它不能解析符號。
按照以下鏈接https://github.com/nostra13/Android-Universal-Image-Loader http://javatechig.com/android/universal-image-loader-library-in提到的步驟-android – Sanjeev