tags:

views:

927

answers:

2

One of my apps has an "opening screen" (basically a menu) that has an EditText followed by several Buttons. The problem is that several of my users are reporting that when they open the app it's automatically popping up the on-screen keyboard without them even touching the EditText. As far as I can tell, all of these users are using the HTC Hero.

Is this a bug in 1.5? Is there anything I can do about it?

A: 

In that version of Android, when a view is inflated, the focus will be set to the first focusable control by default - and if there's no physical keyboard, the on-screen keyboard will pop up.

To fix this, explicitly set focus somewhere else. If focus is set to anything other than an EditText, the on-screen keyboard will not appear.

Have you tried testing this by running Android 1.5 in the emulator?

dmazzoni
I have tried it in the emulator (and just did it again to make sure I wasn't crazy). It acts "right" (meaning no keyboard pop-up). Also, when I originally wrote this my G1 was running 1.5 and it didn't act this way (when they keyboard was "hidden").
fiXedd
I still bet it has something to do with the initial focus. Maybe it's something specific to the HTC Hero, but I'd try setting the focus explicitly to something else and see if that fixes it for your users.
mbaird
Is there any way to give "nothing" focus?
fiXedd
+5  A: 

You can use the following line of code to make sure the keyboard only pops up when a user clicks into an EditText

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 
Donal Rafferty