Pass current item position to inner class?

How can I pass the current Hashmap key position to my inner class?

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?

    public class UpcomingGridViewAdapter extends BaseAdapter {

    public boolean pressedMovieItem;

    Context context;
    ArrayList<HashMap<String, String>> data;
    HashMap<String, String> mylist = new HashMap<>();

    public UpcomingGridViewAdapter(Context a, ArrayList<HashMap<String, String>> d) {
        context = a;
        data = d;

    public int getCount() {
        return data.size();

    public HashMap<String, String> 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(;

        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 = "" + posterPath;

        // load image url into poster

        // load image url into poster

        // Get onclick of item and pass data to singleitemview for upcoming

        convertView.setOnClickListener(new View.OnClickListener() {

            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< Void, Void, Void> {

        protected void onPreExecute() {

         // TODO setup progressdialog


        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));


            return null;

        protected void onPostExecute(Void result) {


           // TODO stop progressdialog




I think you want position in your Click asynctask for that pass your position in asynctask call :

new Click().execute(position);

Then receive it using params like this :

mylist = data.get(params[0]); // get position here which is passed 

If i get you right you only need to execute your AsyncTask with params. See the documentation:

Need Your Help

Change other's property

wpf properties

Right now, I'm learning WPF. Can we change another WPF object's property when an WPF object's property is changed?

Using the return values of dynamic classes

python class oop python-2.7 dynamic

I have a type of file that I work with where each line represents a different "model" and each model has certain attributes. From file to file those attributes can change so I wrote dynamic class t...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.