0

My application starts with a bunch of text input fields, and I want that when starting up the the application. The virtual keyboard isn't open, but opens only when I click on one of the textinput fields. How do I do this?

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
user434885
  • 1,900
  • 6
  • 28
  • 49

3 Answers3

3

In your onCreate method you could get your first text view and call requestFocus() on it. This ought to focus this field when the activity starts and bring up a virtual keyboard if needed.

If you want the keyboard not to appear on startup, request focus for a non-text element like a button.

Nick
  • 11,233
  • 1
  • 34
  • 46
  • Sorry, your question was unclear. Do you have any other focusable elements in your application such as a button? Set one of those to focus instead. – Nick Nov 14 '10 at 15:28
1

You should leave the input method to the user. They might be using a physical keyboard or maybe even something like speech to text.

JOTN
  • 5,870
  • 2
  • 24
  • 30
  • i dont want to get the keyboard to appear ... iwant the keyboard to NOT appear – user434885 Nov 13 '10 at 16:56
  • In that case just don't present an editable field. There's not much reason to have one if you want to block the input method. – JOTN Nov 14 '10 at 21:50
0

I've used this approach to hide the keyboard after the user searches. You could use this in our onCreate method:

Close/hide the Android Soft Keyboard

Quote from Reto Meier's accepted solution:

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
Community
  • 1
  • 1
Computerish
  • 9,434
  • 6
  • 34
  • 47