我正在尝试使用imageLoader通过url加载图像和文本时,在列表视图中填充图像和文本时,显示时
这是我的代码
mall=getIntent().getStringArrayListExtra("text");
mallpos=getIntent().getStringArrayListExtra("Ima");
System.out.println("Images"+mallpos);
System.out.println(mall.size());
for(int i=0;i<mall.size();i++)
{
poss=mall.get(i);
System.out.println("value"+poss);
dto =new locationdto();
dto.setMallname(poss);
rou.add(dto);
}
System.out.println(mallpos.size());
for(int i=0;i<mallpos.size();i++)
{
Ima=mallpos.get(i);
System.out.println("value"+Ima);
dto=new locationdto();
dto.setImage(Ima);
System.out.println("imaghe"+ dto.getImage());
rou.add(dto);
}
lv=(ListView)findViewById(R.id.listm);
System.out.println("Arraysize#############" + rou.size());
System.out.println("Arraysize#############" + rou1.size());
MaterialMasterAdapter adapteer =new MaterialMasterAdapter(MalllistActivity.this, rou);
lv.setAdapter(adapteer);
这是我的适配器代码,我无法纠正错误
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class MaterialMasterAdapter extends BaseAdapter
{
Holder mHolder = null;
private Context mContext;
locationdto dto = new locationdto();
ArrayList<locationdto> a1;
ArrayList<locationdto> arr =new ArrayList<locationdto>();
String a2;
String[] imageurl=null;
ImageLoader imageLoader;
String s;
String urlss;
public MaterialMasterAdapter(Context c,ArrayList<locationdto> arrList1 ) {
// TODO Auto-generated constructor stub
mContext=c;
a1=arrList1;
ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(mContext));
}
public int getCount() {
// TODO Auto-generated method stub
return a1.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return a1.get(position);
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int pos, View child, ViewGroup parent)
{
// TODO Auto-generated method stub
Holder mHolder;
LayoutInflater layoutInflater;
if (child == null)
{
layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
child = layoutInflater.inflate(R.layout.list_layout, null);
mHolder = new Holder();
mHolder.txtitemid = (TextView) child.findViewById(R.id.artist);
mHolder. imageView = (ImageView) child.findViewById(R.id.list_image);
child.setTag(mHolder);
} else
{
mHolder = (Holder) child.getTag();
}
dto=a1.get(pos);
String url=dto.getImage();
mHolder.txtitemid.setText(dto.getMallname());
ImageLoader.getInstance().displayImage(url, mHolder.imageView);
return child;
}
public class Holder
{
TextView txtitemid,txtmat,txtqty,image;
ImageView imageView;
}
}
将两个arraylist合并为一个`
if (mall.size() != mallpos.size()) { // Too many names, or too many numbers
// Fail
}
for (int i = 0; i < mall.size(); i++) { // Loop through every name/phone number combo
array3.add(mall.get(i) + " " + mallpos.get(i)); // Concat the two, and add it
v=mall.get(i);
n=mallpos.get(i);
dto =new locationdto();
dto.setMallname(v);
dto.setImage(n);
rou.add(dto);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句