java - onitemclicklistener shows only last result from json -
class LoadProfile extends AsyncTask & LT; String, string, string & gt; {@Override Secure Zero on PreExecute () {super.onPreExecute (); PDialog = New Progress DiLog (EventCategory.this); PDialog.setMessage ("Loading ..."); PDialog.setIndeterminate (wrong); PDialog.setCancelable (wrong); PDialog.show (); } Protected string doInBackground (string ... args) {// Building parameter String json = null; {List & lt; NameValuePair & gt; Parameters = new arreelist & lt; Named Wolopleyre & gt; (); HTTP Client HTTP Client = New DefaultHttpClient (); Http post httppost = new HTTP post (PROFILE_URL); Httppost.setEntity (new UrlEncodedFormEntity (params)); // Execute HTTP Post Request HTTP Response Response = httpclient.execute (httppost); HttpEntity resEntity = response.getEntity (); Json = EntityUtils.toString (resEntity); Log.i ("All categories:", json.toString ()); } Hold (exception e) {e.printStackTrace (); } Return json; } @Override Protected Zero onPostExecute (string json) {super.onPostExecute (JSON); PDialog.dismiss (); Try {Event_category = New JSONObject (json); Last Arrielist & lt; Hashmap & lt; String, string & gt; & Gt; Arraylist = new arrivals & lieutenant; Hashmap & lt; String, string & gt; & Gt; (); JSONArray user = event_category.getJSONArray ("event_category"); For (int i = 0; i & lt; user.length (); i ++) {JSONObject object = user.getJSONObject (i); Category_id = object.getString ("id"); Logs. I ("id:", category_id); Hashmap & lt; String, string & gt; Map = new hashmap & lt; String, string & gt; (); Map.put ("type", object.getString ("type")); Map.put ("images", object.getString ("picture")); Arraylist.add (map); } From string [] = {"type", "picture"}; Int [] to = {R.id.textView1, R.id.iv_flag}; ListAdapter Adapter = New MyAdapter (EventCategory.this, ArrayList, R.layout.event_category, for, with); Gv1.setAdapter (adapter); Gv1.setOnItemClickListener (New OnItemClickListener) {@Override Public Zero onItemClick (AdapterView & LT;? & Gt; arg0, ARG1, integer ARG2, long arg3) {// TODO Automatic Created Method Stub Toast.makeText (getApplicationContext () , Category_id, toast.LENGTH_SHORT) .show ();}}); } Hold (exception e) {e.printStackTrace (); }}} By clicking any item in my gridview onitemclicklistener it displays only the end result (category_id). What's the problem
Does anyone know the answer because Android is new to it? help please.
Thanks in advance!
Comments
Post a Comment