I have this code-block that is supposed to show a dialog alert box asking for user input that I am storing in a string variable but I am getting a "variable accessed from inner class" error with the variable position and parent. What should I do? Not able to declare this as Final or Public either?
title.setOnItemClickListener(
new AdapterView.OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?>parent, View view, int position, long id) {
AlertDialog.Builder builder = new AlertDialog.Builder(pdf1.this);
builder.setTitle("Title");
// Set up the input
final EditText input = new EditText(pdf1.this);
// Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
builder.setView(input);
// Set up the buttons
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
m_Text = input.getText().toString();
String theitem = String.valueOf(parent.getItemAtPosition(position));
Intent m = new Intent(pdf1.this, noteview.class);
m.putExtra("me", theitem);
m.putExtra("date", datestr);
startActivity(m);
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
}
);