I\'m getting an underline in some variables on Android Studio (in this case on the \'position\' variable). I think it\'s not an error because the application runs perfectly
This means the variable was declared outside the current method. For example, in this case, position is probably declared as a class member outside the new DialogInterface.OnClickListener(), in the class where you're implementing the onItemLongClick() method.
They are declared like this:
public class MyClass{
private int position;
// Other code...
}