Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android edittext typed text not showing

Tags:

android

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

like image 203
Mike Avatar asked Oct 15 '15 01:10

Mike


2 Answers

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"

like image 137
MEGHA DOBARIYA Avatar answered Sep 28 '22 05:09

MEGHA DOBARIYA


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"

like image 34
Mohammed Fathi Avatar answered Sep 28 '22 06:09

Mohammed Fathi