title: How to retrieve value from ArrayList in android
body: <p>I am trying to retrieve values from a <code>json api</code> and displaying then in a listView. The <code>listView</code> contains 3 elements and I am also implementing <code>onItemClickListner()</code> and when an Item is clicked it will display a detailed view related to that item. I am using an <code>ArrayList</code> to store all the <code>json</code> values. Now I want to retrieve a value from that <code>ArrayList</code> so that the <code>OnClickListner()</code> will get that value and from that value the detailed view will be displayed..</p>
  
  <p>I am using AsyncTask to retrieve all the json values</p>
  
  <pre><code>@Override
  protected String doInBackground(String... DATA) {
  if(rqst_type.equals("top5"))
      {
          String url = DATA[1];
          JsonParser jParser = new JsonParser();
          JSONObject json = jParser.getJSONfromUrl(url);
          try
          {
              JSONArray top5 = json.getJSONArray(TAG_TOP5);
              public static ArrayList&lt;HashMap&lt;String, String&gt;&gt; top5List = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
              top5List.clear();
              for(int i=0; i&lt;top5.length(); i++)
              {
                  Log.v(TAG_LOG, "Value of i: "+String.valueOf(i));
                  JSONObject t = top5.getJSONObject(i);
                  course_id = t.getString(TAG_CRSID);
                  created_date = t.getString(TAG_CRTDATE);
                  golfcourse_name = t.getString(TAG_GLFCRSNAME);
                  facilities = t.getString(TAG_FCLTY);
                  holes = t.getString(TAG_HOLES);
  
                  HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                  map.put(TAG_CRSID, course_id);
                  map.put(TAG_CRTDATE, created_date);
                  map.put(TAG_GLFCRSNAME, golfcourse_name);
                  map.put(TAG_FCLTY, facilities);
                  map.put(TAG_HOLES, holes);
  
                  top5List.add(map);
                  Log.v(LoadingScreen.TAG_LOG, "top5List: "+String.valueOf(top5List));
              }
          }
          catch(JSONException e)
          {
              Log.v(TAG_LOG, String.valueOf(e));
          }
  }
  
  protected void onPostExecute(String result) {
      // TODO Auto-generated method stub
      super.onPostExecute(result);
      if(rqst_type.equals("top5"))
      {
          Intent in = new Intent(context, MyTop5.class);
          in.putExtra(TAG_CRSID, course_id);
          in.putExtra(TAG_CRTDATE, created_date);
          in.putExtra(TAG_GLFCRSNAME, golfcourse_name);
          in.putExtra(TAG_FCLTY, facilities);
          in.putExtra(TAG_HOLES, holes);
          Log.v(TAG_LOG, "Valuse to MyTop5: "+course_id+" "+created_date+" "+golfcourse_name+" "+
                  facilities+" "+holes);
          context.startActivity(in);
      }
  </code></pre>
  
  <p>This is the file to where I am displaying the list and the <code>onItenClickListner()</code>..</p>
  
  <pre><code> @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.my_top5);
  
      Intent in = getIntent();
      golfcourse_name = in.getStringExtra(TAG_GLFCRSNAME);
      course_id = in.getStringExtra(TAG_CRSID);
      created_date = in.getStringExtra(TAG_CRTDATE);
      facilities = in.getStringExtra(TAG_FCLTY);
      holes = in.getStringExtra(TAG_HOLES);
      Log.v(LoadingScreen.TAG_LOG, "course id: "+String.valueOf(course_id));
      ListAdapter adapter = new SimpleAdapter(this, LoadingScreen.top5List, R.layout.top5_list,
              new String[] { TAG_GLFCRSNAME, TAG_CRSID, TAG_CRTDATE, TAG_FCLTY, TAG_HOLES },
              new int[] { R.id.top_golfname, R.id.top_courseid, R.id.top_createdate, R.id.top_fclty, R.id.top_holes });
  
      setListAdapter(adapter);
      Log.v(LoadingScreen.TAG_LOG, "course id: "+String.valueOf(course_id));
      ListView lv = getListView();
  
      lv.setOnItemClickListener(new OnItemClickListener() {
  
          public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                  long arg3) {
              // TODO Auto-generated method stub
              String url = "http://mygogolfteetime.com/iphone/viewdeal/127";
              new LoadingScreen(MyTop5.this).execute("view_detail", url);
          }
      });
  }
  </code></pre>
  
  <p>In the given URL I want to change the 127 to the value which is stored in the <code>top5List</code>.</p>
  
  <pre><code>String url = "http://mygogolfteetime.com/iphone/viewdeal/127";
  </code></pre>
  
  <p>The value I am trying to find in the <code>top5List</code> is the value of "<code>course_id</code>"</p>
  
  <p>Thanks in advance..</p>