Hard Keyboard Failed to focus edittext

I have a regular EditText. This is very strange because I can’t focus it when I use a hard keyboard. Context Condition:

  • switch Droid hardkeyboard on
  • get started
  • click editText to enter
  • Failed to enter. When you press any key, the lost focus is editText.

To get focus: press Dpad and you will see that the focus starts with the first widget on the screen. And finally, focus on the target EditText. Then you can enter. Without this, you cannot type with a hard keyboard at all.

The soft keyboard does not have such a focus problem.

I am using android 2.2. Is this a system error?

+8
android android-edittext keyboard
source share
2 answers

As mentioned above, this is clearly a bug with a hard keyboard. If your layout has EditText and TabHost, when you press the first key, EditText will lose focus and the keystroke will be sent to activity. Here is the work on this issue. Realize this in your activities.

@Override public boolean onKeyDown(int keyCode, KeyEvent event){ final EditText myInputField = (EditText) findViewById(R.id.MyInputEditText); // this will happen on first key pressed on hard-keyboard only. Once myInputField // gets the focus again, it will automatically receive further key presses. if (!myInputField.hasFocus()){ myInputField.requestFocus(); myInputField.onKeyDown(keyCode, event); } return super.onKeyDown(keyCode, event); } 

if you have multiple EditText fields, you will need to track the current focused EditText in the class variable and use it in the onKeyDown method.

+9
source share

I have the same problem. I agree with Jay. Typically, TabHost and / or TabActivity use the LocalActivityManager, which tracks inline actions or the corresponding ContentStrategy component that is displayed in the FrameLayout element. In simple words, this is a typical problem with the inline view of work / inline views. Text editing is located at the very top of the Activity / View section, which takes up space on the touch screen, while there is the main Activity actually placing this Activity / View, which probably captures the focus of the InputMethodService and keeps it from editing text, only for a script with a hard keyboard. The soft keyboard works fine.

One change I made with my Text Editing is to change the InputType as pure decimal. Therefore, when Edit Text gains focus, the soft keyboard displays the numeric keypad, not the qwerty alphabetic keyboard. I ran it on a Motorla Droid Pro emulator, which I updated in the Eclipse plugins from Motodev. Apparently, when I try to enter text from the hard keyboard after you gave the focus to edit the text (and the soft keyboard shows the numeric keyboards), after I press "ALT + 2", the soft keyboard reboots like an alphabetic keyboard, and Edit Text completely loses focus.

It seems like a serious mistake in the release of Froyo, insufficient support for hard keyboard devices for editing text presentations in layouts (LinearLayout), embedded in other layouts (FrameLayout from TabHost).

0
source share

All Articles