So I have an onItemLongClickListener for a list view that gets a parameter \'int position\' passed in. Inside, I have an alertDialogBuilder which has two buttons. I have another
In Java, you can access outer variables from an inner class declaration only if they are first declared as final
. So you could add:
final int selectedPosition = position;
to the top of your method and use that value in your extra, i.e.
intent.putExtra("position", selectedPosition);
If you change position to final, then it should let you access it from within the onClick method.