-1
我在互聯網上有XML文件我解析它並獲得String的arrayList代表圖像的URL我需要動態地創建這些圖像的網格視圖。 我的問題是,當我試圖在網格視圖中顯示這些圖像時,它們顯示爲一列。我不知道如何解決這個問題。 這裏ImageAdapter.java如何使android gridView顯示多列
public class ImageAdapter extends BaseAdapter {
private Context mContext;
private Serializable mThumbIds ;
ImageDownLoader imageDownloader;
private String img_url;
int item_id;
ConnectorInterface _conn=new ConnectorImpl();
public ImageAdapter(Context c) {
mContext = c;
}
public ImageAdapter(Context c,Serializable a){
mContext=c;
mThumbIds= a;
}
public int getCount() {
return ((ArrayList<ItemEntity>)mThumbIds).size();
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return item_id;
}
// create a new ImageView for each items referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView = null ;
for (int x=0;x<((ArrayList<ItemEntity>) mThumbIds).size();x++){
imageView = new ImageView(mContext);
if (convertView == null) {
imageDownloader = new ImageDownLoader(imageView);
imageDownloader.execute(((ArrayList<ItemEntity>) mThumbIds).get(x).getThumbnailImg());
imageView.setLayoutParams(new GridView.LayoutParams(50,50));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(2,2,2,2);
imageView.setVisibility(View.VISIBLE);
} else {
imageView = (ImageView) convertView;
}
}
return imageView;
}
}
我需要幫助PLZ;
我已經做到了,但沒有way.when我指定的數它dublicates通過thiink我有問題在adapter.i返回相同的圖像如何循環和從適配器中退出 –