I have a Listfragment like this :
private ArrayList<String>images;
private View view;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.activity_torrent_detail_images, container, false);
SetAdapter();
return view;
}
public void SetImages(ArrayList<String> images) {
this.images = images;
}
public void SetAdapter() {
if(images!= null && view != null) {
if(this.getActivity() != null) {
this.setListAdapter(new ImageAdapter(this.getActivity(),this.images));
}
}
}
here's my adapter:
public class ImageAdapter extends ArrayAdapter<String> {
private final Context context;
private final ArrayList<String> images;
App app;
public ImageAdapter(Context context,
ArrayList<String> images) {
super(context, R.layout.search_row, images);
this.context = context;
this.images = images;
app =((App)context.getApplicationContext());
}
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.imagesrow, parent, false);
ImageView img = (ImageView)rowView.findViewById(R.id.imgImage);
app.imageLoader.displayImage(images.get(position), img);//this load the image from the http
return rowView;
}
}
Finally, in my activity
fragImages.SetImages(ListImage);
The problem is that the listview only shows the first image. I've look in the ListImage and it contains 3 items, so the listview should show 3 images. Did I miss anything? thanks a lot.