I would like someone to explain the 2 following behaviors.
I start with this screen:
When I touch the text area inside "City You're From", I get the following screen:
When I hit the keyboard's "Done" button, I go back to the original state as expected. In other words, the hidden boxes are made visible again and the cursor is gone( the EditText no longer has focus ). How this happens is I just have a listener waiting for that "Done" button to be pressed. When that happens, I call clearFocus()
on the EditText
view. I then have a OnFocusChangeListener
which makes all the boxes invisible/visible depending on whether an EditText has focus or not.
HOWEVER, I only get this expected behavior when I set an ancestor layout (i.e. a parent or grandparent RelativeLayout) with the following property: android:focusableInTouchMode="true"
OTHERWISE, I get the following screen:
When clearFocus()
is called, it jumps down to the next child in the hieararchy which is "Current City" and gives that EditText
focus (and hides the keyboard but that's part of the expected behavior).
Clicking on "Current City" in screen 1 results in screen 3 as well if I do not set android:focusableInTouchMode="true"
. In other words, it remains at "Current City" and does not lose focus.
Question
Can someone please explain what is going on? Why does leaving out android:focusableInTouchMode="true"
cause such strange behavior?