Code example for GridView

Methods: setAdapter, setOnItemClickListener

0
		protected void onPostExecute(Bitmap[] result) {
			super.onPostExecute(result);
		 
			final ThumbnailAdapter adapter = new ThumbnailAdapter(mContext, objects, result);
			GridView lv = (GridView)findViewById(android.R.id.list);
			lv.setAdapter(adapter);
			lv.setOnItemClickListener(new OnItemClickListener() {
				 
				public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
					try { 
						Uri downloadUri = Uri.parse(
								((JSONObject)adapter.getItem(position)).getString("MediaUrl"));
						DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
						DownloadManager.Request dr = new DownloadManager.Request(downloadUri); //Uriってなんですか?
						String fn = URLDecoder.decode(downloadUri.getLastPathSegment(),"UTF-8");
						 
						dr.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fn);
						dm.enqueue(dr);
					} catch (JSONException e) {
						e.printStackTrace();
Stop searching for code, let great code find you!  Add Codota to your java IDE