tags:

views:

225

answers:

2

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?

+2  A: 

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).

synic
A: 

Hi,

I was facing a similar problem. I also had the following observation. I have an activity with two edittext controls. I was calling the requestFocus on the second edittext field since by default the focus goes to the first edittext control. The focus appears to be in the second edittext field (the second one gets the highlighted border), but if we try to enter any characters using the hardware keyboard the text appears in the first edittext control. My activity is not a tab activity. Any ideas why it may be happening?

Regards, Ashish

Ashish
Best to ask this in another question, instead of as an answer to this one. You won't get any karma points this way.
synic