title: Pass current item position to inner class?
body: <p>How can I pass the current Hashmap key position to my inner class?</p>
  
  <p>I need to pass data.get(position) to my inner class Click. Normally I would declare it final, but I'm not seeing how this is done in this case?</p>
  
  <pre><code>    public class UpcomingGridViewAdapter extends BaseAdapter {
  
      public boolean pressedMovieItem;
  
      Context context;
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; data;
      HashMap&lt;String, String&gt; mylist = new HashMap&lt;&gt;();
  
      public UpcomingGridViewAdapter(Context a, ArrayList&lt;HashMap&lt;String, String&gt;&gt; d) {
          context = a;
          data = d;
      }
  
      public int getCount() {
          return data.size();
      }
  
      public HashMap&lt;String, String&gt; getItem(int position) {
          return data.get(position);
      }
  
      public long getItemId(int position) {
          return position;
      }
  
      public View getView(final int position, View convertView, ViewGroup parent) {
  
          if (convertView == null) {
              LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = inflater.inflate(R.layout.upcoming_grid_item, parent, false);
          }
          final ImageView poster = (ImageView) convertView.findViewById(R.id.upcoming_image);
  
  
  
  
          mylist = data.get(position);
  
  
          final String posterPath = mylist.get("poster_path");
  
  
          // set image url correctly
          // sizes for image 45, 92, 154, 185, 300, 500
          final String url = "http://image.tmdb.org/t/p/w185" + posterPath;
  
  
          // load image url into poster
          Picasso.with(context).load(url).into(poster);
  
          // load image url into poster
  
          // Get onclick of item and pass data to singleitemview for upcoming
  
          convertView.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View arg0) {
  
  
            // need to pass data.get(position) to the inner class click
            new Click().execute();
  
              }
          });
  
          return convertView;
  
  
      }
  
      // Downloading data asynchronously
      class Click extends AsyncTask&lt; Void, Void, Void&gt; {
  
          @Override
          protected void onPreExecute() {
  
           // TODO setup progressdialog
  
          }
  
          @Override
          protected Void doInBackground(Void... params) {
  
  
              mylist = data.get(position); // need to get position 
  
              Intent intent = new Intent(context, UpcomingSingleItem.class);
  
              intent.putExtra("poster_path", mylist.get(Upcoming.TAG_POSTER));
  
              intent.putExtra("title", mylist.get(Upcoming.TAG_TITLE));
  
              intent.putExtra("release_date", mylist.get(Upcoming.TAG_RELEASE));
  
              intent.putExtra("overview", mylist.get(Upcoming.TAG_OVERVIEW));
  
              intent.putExtra("id", mylist.get(Upcoming.TAG_ID));
  
              intent.putExtra("vote_average", mylist.get(Upcoming.TAG_VOTE_AVG));
  
  
              context.startActivity(intent);
  
  
              return null;
          }
  
  
          @Override
          protected void onPostExecute(Void result) {
  
              super.onPostExecute(result);
  
             // TODO stop progressdialog
          }
  
      }
  
  }
  </code></pre>