0

In Xamarin, I am implementing a date field, with a DatePickerDialog returning to an EditText. I've disabled the cursor and disabled soft input like this. I've assigned the Click event of the EditText to launch the dialog. And to my surprise, the first click on the field serves just to pull the focus onto the field. The little line underneath turns blue. I need to click again to get my Click handler to fire and launch the dialog. It would be nice if it popped first time.

Why is this so? Am I too hung up on mice to appreciate the subtleties of a touch interface? Should I be listening for a different event?

Community
  • 1
  • 1
bbsimonbb
  • 27,056
  • 15
  • 80
  • 110

1 Answers1

1

Don't know about Xamarin syntax, but, in Android you can do this by adding these attributes to your EditText in xml:

android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"

or in Java like this:

editText.setClickable(false);
editText.setFocusable(false);
editText.setFocusableInTouchMode(false);
Rehan
  • 3,270
  • 5
  • 31
  • 30
  • 1
    Xamarin would be `editText.Clickable = false;`, etc. Some methods anyway. – Johan Oct 08 '15 at 08:12
  • Yes but I want to catch the click event, and to keep the focus. I can work around by catching the touch event and calling performClick(), but I still don't understand. – bbsimonbb Oct 08 '15 at 12:41
  • @user1585345 Did you try this code? Your click event will be called on the first click. This snippet does not prevent your listener from being called, but just stops the call to default event, which results in calling your event on the first click – Rehan Oct 08 '15 at 18:14