title: How to get HashMap id value in ListView onItemClick?
body: <p>I tried to add ImageList to my application. i added it successfully. It shows Logos of banks which i was selected. I added that through <strong>HashMap</strong>, because i want to take bank name when click the log image. </p>
  
  <p>But i can't get the bank name in <strong>onItemClick</strong> method. Can anyone help me to fix this problem?</p>
  
  <p>This is my Activity code.</p>
  
  <pre><code>public void getImageData() {
  
      map = new HashMap&lt;String, String&gt;();
  
      try {
          JSONObject jsonResponse = new JSONObject(strJson1);
          JSONArray jsonMainNode = jsonResponse.optJSONArray("bank");
  
          for (int i = 0; i &lt; jsonMainNode.length(); i++) {
              JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
              img_url = jsonChildNode.optString("logo");
              String test1 = img_test_url + img_url;
              bName = jsonChildNode.optString("name");
              map.put(bName, test1);
  
          }
  
          ItemsAdapter adapter = new ItemsAdapter(getApplicationContext(),map);
          list.setAdapter(adapter);
  
      } catch (JSONException e) {
          Toast.makeText(getApplicationContext(), "Connection Error...",
                  Toast.LENGTH_LONG).show();
      }
  
      list.setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                  long arg3) {
              // TODO Auto-generated method stub
  
              HashMap&lt;String, String&gt; obj = (HashMap&lt;String, String&gt;) adapter.getItem(arg2);
              String name = (String) obj.get("bName");
              Log.d("Bank Name", name);
  
          }
      });
  }
  </code></pre>
  
  <p>This is my Adapter class</p>
  
  <pre><code>public class ItemsAdapter extends BaseAdapter {
  
      private final Context context;
      ImageView imageView;
      private String[] mKeys;
      HashMap&lt;String, String&gt; map;
  
      ItemsAdapter(Context context, HashMap&lt;String, String&gt; map) {
  
          this.context = context;
          this.map = map;
          mKeys = map.keySet().toArray(new String[map.size()]);
  }
  
      @Override
      public int getCount() {
          // TODO Auto-generated method stub
          return map.size();
      }
  
      @Override
      public Object getItem(int position) {
  
          return map.get(mKeys[position]);
      }
      @Override
      public long getItemId(int position) {
          // TODO Auto-generated method stub
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          String key = mKeys[position];
          String Value = getItem(position).toString();
  
              LayoutInflater inflater = (LayoutInflater) context
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
              View rowView = convertView;
              if (null == convertView)
                  rowView = inflater.inflate(R.layout.items, parent, false);
              imageView = (ImageView) rowView.findViewById(R.id.imageView1);
              Bitmap bitmap;
              URL imageURL = null;
  
  
              Log.d("value", Value);
              Log.d("key", key);
          try {
              imageURL = new URL(Value);
          }
  
          catch (MalformedURLException e) {
              e.printStackTrace();
          }
  
          try {
              HttpURLConnection connection = (HttpURLConnection) imageURL.openConnection();
              connection.setDoInput(true);
              connection.connect();
              InputStream inputStream = connection.getInputStream();
  
              bitmap = BitmapFactory.decodeStream(inputStream);// Convert to bitmap
              imageView.setImageBitmap(bitmap);
          } catch (IOException e) {
  
              e.printStackTrace();
          }
  
              return rowView ;
          }
  }
  </code></pre>
  
  <p>This is LogCat error.</p>
  
  <pre><code>03-17 13:58:13.620: E/AndroidRuntime(10172): FATAL EXCEPTION: main
  03-17 13:58:13.620: E/AndroidRuntime(10172): java.lang.NullPointerException
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at com.example.testhashimage.MainActivity$1.onItemClick(MainActivity.java:161)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at android.widget.AdapterView.performItemClick(AdapterView.java:301)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at android.widget.AbsListView.performItemClick(AbsListView.java:1280)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:3071)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at android.widget.AbsListView$1.run(AbsListView.java:3973)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at android.os.Handler.handleCallback(Handler.java:615)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at android.os.Handler.dispatchMessage(Handler.java:92)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at android.os.Looper.loop(Looper.java:137)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at android.app.ActivityThread.main(ActivityThread.java:4960)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at java.lang.reflect.Method.invokeNative(Native Method)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at java.lang.reflect.Method.invoke(Method.java:511)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
  03-17 13:58:13.620: E/AndroidRuntime(10172):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>