EditText calls onFocusChanged three times instead of once
Asked Answered
A

0

7

I have to do a ListView that contains on each item an EditText. If the EditText receives focus, I have to display a dialog - the condition is strictly for when the EditText receives focus and not when is pressed because it can be selected even if it is not pressed...

To do this I use a focus listener on the EditText but the onFocusChanged gets called three times instead on only one when the user presses the EditText, this means the dialog gets called twice...

This is the sequence of the calls:

  • Has focus
  • Lost focus
  • Has focus

I don't have any other special handling of the ListView or EditText .. so it should be from the system somehow, maybe because I am using the EditText on the ListView which is a focusable View too..

Does anyone have any ideas why is this happening and how can I "fix" this?

Thank you in advance.

Apgar answered 25/6, 2013 at 17:29 Comment(3)
EditText inside a ListView has always been a lethal combination. Try inflating a LinearLayout instead, the issue might get resolved.Kowalczyk
@ShishirShetty Can you be more specific ? ThanksGaptoothed
https://mcmap.net/q/1047744/-how-to-inflate-android-view-in-linearlayout-class something like this.Kowalczyk

© 2022 - 2024 — McMap. All rights reserved.