Android ArrayList<;字符串>;图像URL填充在GridView内部
我想在GridView上显示图像,并从JSON URL填充它 这是我的代码,我有ArrayList现在想从URL在GridView上显示这些图像Android ArrayList<;字符串>;图像URL填充在GridView内部,android,Android,我想在GridView上显示图像,并从JSON URL填充它 这是我的代码,我有ArrayList现在想从URL在GridView上显示这些图像 ArrayList<String> ImgArray = new ArrayList<String>(); private class DownloadFilesTask extends AsyncTask<Void, Void, Void> { private ProgressDialog pDialo
ArrayList<String> ImgArray = new ArrayList<String>();
private class DownloadFilesTask extends AsyncTask<Void, Void, Void> {
private ProgressDialog pDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
// before making http calls
Log.e("JSON", "Pre execute");
ImgArray.clear();
newArray.clear();
galleryArray.clear();
pDialog = new ProgressDialog(PhotosDetail.this);
pDialog.setMessage("Getting Data ...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
JSONParser jsonParser = new JSONParser();
JSONArray json = jsonParser.getJSONFromUrl(url, category, galleryid);
if (json != null) {
try {
for (int i = 0; i < json.length(); i++) {
JSONObject arr = json.getJSONObject(i);
newArray.add(arr.getString(TAG_NAME));
galleryArray.add(arr.getString(TAG_GALLERY));
String image = arr.getString(TAG_IMAGE);
image = "http://fromwebsite.net/media" + image;
ImgArray.add(image);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return null;
}
@Override
protected void onPostExecute(Void result) {
pDialog.dismiss();
//What I want here to populate "ImgArray.add(image)" on GridView
}
}
提前感谢您还没有说要做什么,但我想它即将从URL加载图像。然后你只需要把位图放到ImageView中,然后把它们放到你的网格中。谢谢你做了什么?请发布一个更具体的问题!您面临什么问题?亲爱的@PranavSingh,我使用通用图像加载器解决了这个问题,现在应用程序已提交到Google Play store.:)我想从JSON URL在GridView上显示图像,检查Gallery图像数组值将代码放入for()中,将其应用于所有图像,并将其存储在向量中,然后将其放入onPostExecute()中的GridView抱歉,我是Android开发的新手,请分享一些示例代码。
Gallery Image Array: [http://fromwebsiteurl.net/media/image/0001.jpg, http://fromwebsiteurl.net/media/image/0002.jpg, http://fromwebsiteurl.net/media/image/0003
.jpg, http://fromwebsiteurl.net/media/image/0004.jpg, http://fromwebsiteurl.net/media/image/0005.jpg, http://fromwebsiteurl.net/media/image/0006.jpg, http://fromwebsiteurl.net/media/image/0007.jpg, http://fromwebsiteurl.net/media/image/0008.jpg, http://fromwebsiteurl.net/media/image/0009.jpg, http://fromwebsiteurl.net/media/image/0010.jpg, http://fromwebsiteurl.net/media/image/0011.jpg, http://fromwebsiteurl.net/media/image/0012.jpg, http://fromwebsiteurl.net/media/image/0013.jpg, http://fromwebsiteurl.net/media/image/0014.jpg, http://fromwebsiteurl.net/media/image/0015.jpg, http://fromwebsiteurl.net/media/image/0016.jpg, http://fromwebsiteurl.net/media/image/0017.jpg, http://fromwebsiteurl.net/media/image/0018.jpg, http://fromwebsiteurl.net/media/image/0019.jpg, http://fromwebsiteurl.net/media/image/0020.jpg]