Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't focus EditText

I have a simple EditText inside my scrollview. All the other elements are working just fine, however i won't get the usual EditText behaviour on click (Keyboard doesn't appear, I can't write).

Here's my xml for the field.

       <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/enterWishprice"
            android:background="@drawable/edit_back"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:text="0 F€"
            android:gravity="center_vertical|center_horizontal"
            android:textSize="26dp"
            android:inputType="number"
            android:layout_margin="10dp" />

As you can see I already tried setting focusable/inTouchMode. I also tried setting a click listener on the field to manually open the keyboard which works just fine. However I still can't type anything into the field. After that i tried using requestFocus in the clicklistener without any result. Furthermore I tried clearFocus on the EditText as well as the surrounding ScrollView - also not working.

Hopefully you can give me a hint cause I'm out of ideas.. Thanks in advance!

like image 697
user2700475 Avatar asked Nov 22 '22 17:11

user2700475


1 Answers

The attribute Enabled must be set to true.

<EditText
        android:id="@+id/room_message"
        android:layout_width="164dp"
        android:layout_height="46dp"
        android:clickable="true"
        android:ems="10"
        android:enabled="true"
        android:focusableInTouchMode="true"
        android:hint="@string/prompt_message"
        android:inputType="textPersonName"
        android:textColor="#FFFFFF"
        android:textSize="18sp"
        android:textStyle="italic"
        />

But i have got another problem where the EditText won't lose focus....

like image 117
Panagiss Avatar answered Mar 07 '23 17:03

Panagiss