vignesh kumar
vignesh kumar

Reputation: 2330

Xamarin.Forms Entry.Focus() is not working in Android 9 and 10

In a sample Xamarin.Forms application we are trying to focus an Entry field after it becomes Visible on a Button Click

Below is the code snippet we are using to achieve above behavior I mentioned

void OnClick(object sender,EventArgs arg)
{
      searchEntry.IsVisible = true;
      searchEntry.Focus();
}

This is working fine in all iOS devices and android devices below 9 for android 9 and 10 the keypad shows up but the typed letters are not getting reflected in the Entry fields.

Can anyone have experienced the same issue before? Please let me know if there is any solution for that in the Answers section.

Upvotes: 1

Views: 1490

Answers (1)

Adlorem
Adlorem

Reputation: 1517

Give device some time to process previous request.

(void)OnClick(object sender,EventArgs arg)
{
      searchEntry.IsVisible = true;
      await Task.Delay(500);
      searchEntry.Focus();
}

Upvotes: 2

Related Questions