In the onCreate() of an activity, I’ve got a call to requestFocus() on an EditText. Immediately after, I’ve got the following:
System.out.println(mEdit.isFocusableInTouchMode());
System.out.println(mEdit.isFocusable());
System.out.println(mEdit.isFocused());
These were just put in while I was trying to figure out what is wrong with this activity… they all print “true”. However, as you may have guessed, the EditText does NOT have focus, and if I try to start typing, nothing happens. I have to click on the EditText to being typing.
I can’t see that anything else has focus, but obviously something has to have it.. how can I find out what it is?
I think I figured it out. It was due to this activity being in a TabActivity. Apparently when you click on a tab, TabHost just calls requestFocus(FOCUS_FORWARD) on the tab content view (I found this in TabHost.java).