tags:

views:

40

answers:

0

I have encountered a very weird problem with using the physical/hardware keyboard when typing in an EditText.

It would have been simpler if all hardware keyboard input in any EditText didn't work. But its not, in one Activity, typing with they device keyboard in the EditText works, but in another Activity, typing loses the focus of the EditText and couldn't type anymore.

The following are the differences between the two Activities:

  • Problematic EditText is in another layout and has been called using INCLUDE in the Activity's main layout file
  • The main layout where Problematic EditText is has a TABHOST root element as compared to LinearLayout of the working EditText
  • The main layout where problematic EditText is has other elements like RadioButton

Another thing to note is that device keyboard input in the problematic EditText works when doing the following:

  1. Click on the EditText field.
  2. Use DPAD and scroll right twice. This makes EditText lose focus and gain focus once more.
  3. Type using device keyboard or computer keyboard.

I couldn't find the reason behind why its not working.

While troubleshooting, I've setup listeners to determine if the said EditText has focus when clicking/touching it, and clearly it has. But as soon as I start typing, it loses that focus.

Btw, what's the difference of having focus (hasFocus or isFocused) and having an orange border around the EditText view?

This is the xml for the EditText:

<EditText
    android:layout_width="150dip"
    android:layout_height="wrap_content"
    android:layout_gravity="left"
    android:inputType="text"
    android:text=""
    android:singleLine="true"
    android:editable="true"
    android:padding="2dip" />

UPDATE:

Looks like we've narrowed down the cause of the problem. Further troubleshooting indicated that problem only occurs upon setting the content of each TAB using setContent.

tabHost.addTab(tabHost.newTabSpec("msgs").setIndicator("Messages").setContent(R.id.mytext_view));

We have tried using the three different ways (using Intents to load an activity, using view ids to load views, and using the tabcontentfactory) you can set content for a tab, and all approaches will have the EditText failure.

Commenting out these setContent lines of code, makes the EditText input from device keyboard possible.

Perhaps you guys can provide input?