我有應用程序使用Volley庫查看json數據到gridview(圖像&文本)。有一次,我點擊GridView的圖片和文字是傳遞給下一個活動 我可以使用的GridView適配器必須ArrayList的一個圖像和其他文本 這裏是適配器Json圖像傳遞到下一個活動
public class GridViewAdapter extends BaseAdapter implements Filterable {
//Imageloader to load images
private ImageLoader imageLoader;
private ItemFilter mFilter = new ItemFilter();
//Context
private Context context;
//Array List that would contain the urls and the titles for the images
private ArrayList<String> images;
private ArrayList<String> names;
public GridViewAdapter (Context context, ArrayList<String> images, ArrayList<String> names){
//Getting all the values
this.context = context;
this.images = images;
this.names = names;
}
@Override
public int getCount() {
return images.size();
}
@Override
public Object getItem(int position) {
return images.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
//Creating a linear layout
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
//HttpsURLConnection.setFollowRedirects(true);
//NetworkImageView
NetworkImageView networkImageView = new NetworkImageView(context);
//NetworkImageView networkImageView = (NetworkImageView) convertView
// .findViewById(R.id.gridimage);
//Initializing ImageLoader
imageLoader = CustomVolleyRequest.getInstance(context).getImageLoader();
imageLoader.get(images.get(position), ImageLoader.getImageListener(networkImageView, R.drawable.ic_launcher, android.R.drawable.ic_dialog_alert));
//Setting the image url to load
networkImageView.setImageUrl(images.get(position),imageLoader);
//Creating a textview to show the title
TextView textView = new TextView(context);
textView.setText(names.get(position));
//Scaling the imageview
networkImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
networkImageView.setLayoutParams(new GridView.LayoutParams(300,300));
//Adding views to the layout
linearLayout.addView(textView);
linearLayout.addView(networkImageView);
//Returnint the layout
return linearLayout;
}
@Override
public Filter getFilter() {
// TODO Auto-generated method stub
return mFilter;
}
}
什麼似乎是問題 – Vucko