10

I know I've seen this question a thousand times by now, but haven't found an answer that has worked. In my app I have an Edittext box. When I run the app on the emulator or my phone, no text shows when typing in the edittext. The cursor moves, and I can get the value that I typed in, just nothing shows while typing. I've tried changing the color of the text, the color of the background and every other solution that I've come across, but nothing has worked.

Here is my xml for the edittext

 <EditText android:id="@+id/editChannel_no"
        android:layout_toRightOf="@+id/Channo"
        android:layout_width="35dp"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/Channo"
        android:inputType="number"
        android:hint="2"
        android:cursorVisible="true" />

Here is the only code used with the edittext

 EditText editChannel_no;
    Button btnSearch;
    Button btnShowAll;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //<item android:id="@+id/action_settings" android:title="@string/action_settings"
        //android:orderInCategory="100" app:showAsAction="never" />


        editChannel_no=(EditText)findViewById(R.id.editChannel_no);
        editChannel_no.requestFocus();
        btnSearch=(Button)findViewById(R.id.btnSearch);
        btnShowAll=(Button)findViewById(R.id.btnShowAll);

        editChannel_no.setTextColor(Color.BLACK);

I've been trying to find a solution for 2 days now, and anyone that solves this will be my hero.

Thanks

Mike
  • 125
  • 1
  • 1
  • 6
  • Can you please post the full xml ? – Santanu Oct 15 '15 at 02:02
  • Out of curiosity, does setting the layout_width to something like match_parent make any difference? Also, if the id.Channo element's height is too small, the edit text will shrink in size. – jyanks Oct 15 '15 at 02:02
  • 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:41

5 Answers5

4
Please add this line in to the <activity>
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
</Activity>
 and Remove the line from manifest file android:hardwareAccelerated="false"
MEGHA DOBARIYA
  • 1,622
  • 9
  • 7
  • 2
    i have remove android:hardwareAccelerated="false" and its working fine – varotariya vajsi Jun 16 '20 at 14:48
  • WOW.... amazing. The issue is that I don't remember why I had it disabled (false)... it fixes this but I am afraid what else could break in other parts of the app LOL. Android never ceases to amaze me. – Daniele Muscetta Mar 10 '23 at 14:21
2

Tried out your code - in my emulator it's working as expected (I am using Genymotion). Are you sure you are typing numbers in the Edittext? android:inputType="number" specifies you only enter number as inputs.enter image description here

Santanu
  • 168
  • 7
2

I have had a similar problem where what I am typing does not appear unless I dismiss the keyboard by clicking the back button, I solved it by this to the activity in the manfiest :

android:windowSoftInputMode="adjustResize"

instead of android:windowSoftInputMode="adjustPan"

Mohammed Fathi
  • 1,237
  • 1
  • 14
  • 12
1

After all this time, the issue was that the edittext was to close to the title bar. Shows how much of a noob I am at android programming.

Mike
  • 125
  • 1
  • 1
  • 6
  • I wish you'd elaborated on this a bit more. I have this same issue with some devices, but I don't see how the title bar affected the edit text, especially when you can still see the cursor move. – Andrew May 10 '21 at 15:06
0

I run the same XML code of you that working fine in my case enter image description here
what you can do is

  1. Restart your Android Studio if you are using it otherwise the IDE you are using.
  2. Sync. your project using the below icon.

Run again one of the above should work.

enter image description here

Inzimam Tariq IT
  • 6,548
  • 8
  • 42
  • 69