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 onclickListener for the buttons. I need to access the position from inside the second listener. Is there anyway to do this without making it a global?
public boolean onItemLongClick(AdapterView parent, View itemView, int position, long id){
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(BookFace.this);
alertDialogBuilder.setTitle("Choose an option.");
alertDialogBuilder
.setMessage("What would you like to do?")
.setCancelable(true)
.setPositiveButton("Edit", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent();
intent.putExtra("position", position); //Can't access this variable
intent.setClass(SomeClass.this, EditActivity.class);
startActivity(intent);
}
Thanks for your help.