6

In my Android application I have an EditText which is sat inside a LinearLayout. This page is used in a ViewPager.

On majority of the devices I have tested on, it seems that the EditText behaves perfectly fine, except on a few.

It appears that on a few devices, when I touch the EditText and start typing, the text doesn't show but the suggestions do show. It is only after the Keyboard is closed that the text appears within the EditText.

Why is this the case? Why does the text not show whilst I type? Why does it show only after I close the keyboard?

Code:

<RadioGroup
    android:id="@+id/searchGroup"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginBottom="10dp">

...
...

<EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="textCapWords|textPostalAddress"
        android:id="@+id/searchText"
        android:hint="@string/locationHint"
        android:imeOptions="actionDone"
        android:layout_below="@+id/locationGroup"
        android:layout_margin="10dp"
        android:singleLine="true"/>

...
...
</LinearLayout>

Update The EditText works fine if it's outside of the ViewPager`. It's only inside the ViewPager that it misbehaves.

Subby
  • 5,370
  • 15
  • 70
  • 125
  • Please try logging out the text in the EditText in `onTextChanged` and provide the result. – Huy Tran Jul 23 '14 at 13:45
  • The `onTextChanged` and `afterTextChanged` are working perfectly fine. – Subby Jul 23 '14 at 14:00
  • See if you have the same problem [here](http://stackoverflow.com/questions/21711237/edittext-in-android-doesnt-show-text-when-typing-while-using-the-on-screen-keyb) – Huy Tran Jul 23 '14 at 15:49
  • @HuyTran I have seen that and it wasn't helpful. The OP made a silly mistake by locking the UI thread. – Subby Jul 24 '14 at 08:21
  • Try setting the text color to black. – Huy Tran Jul 24 '14 at 08:43
  • Tried that. Doesn't work. – Subby Jul 24 '14 at 09:37
  • Hmm, what are the few devices that you mentioned? – Huy Tran Jul 24 '14 at 10:42
  • Sony Xperia, Galaxy S3, Nexus 7...And probably more. – Subby Jul 24 '14 at 12:52
  • You said `onTextChanged` works perfectly fine. Does that mean the text you got using `getText()` is correctly updated every time you type in the EditText? – Huy Tran Jul 24 '14 at 12:59
  • please provide more code.. – Ankit Popli Jul 31 '14 at 17:00
  • hack: you can try setting from `onTextChanged` or `afterTextChanged`, since that works perfectly fine, it is just a hack even if it works. – Ankit Popli Jul 31 '14 at 17:02
  • @Subby I have seen this issue before. Are you using `myEditText.setText("")` to clear the EditText? If you are, replace that call with `TextKeyListener.clear(myEditText.getText())` or `myEditText.getText().clear()`. If that doesn't help, check if `Spell checker` is turned on in `Settings -> Language & input`. Try switching the `Spell checker` off and see if that makes a difference. – Vikram Jul 31 '14 at 19:25
  • It works for me may b help full to others as well, http://stackoverflow.com/questions/21711237/edittext-in-android-doesnt-show-text-when-typing-while-using-the-on-screen-keyb/41425153#41425153 – Naeem Ibrahim Jan 02 '17 at 10:43

1 Answers1

14

Having come across this issue at work with a number of devices and pulling my hair out (which I am sure you can appreciate) I found that wrapping the edittext view in a scrollview resolves the problem. The properties of the scrollview can be set so as not to affect the layout of your view.

Bounty me boy.

Gapp
  • 1,156
  • 8
  • 9
  • Wow that worked! Thanks a lot! Take my 500 points! You deserve it! – Subby Aug 01 '14 at 08:22
  • 1
    It works for me may b help full to others as well, http://stackoverflow.com/questions/21711237/edittext-in-android-doesnt-show-text-when-typing-while-using-the-on-screen-keyb/41425153#41425153 – Naeem Ibrahim Jan 02 '17 at 10:43