Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Can't type in an EditText

I don't know why but I can't type/write on the EditText when I try to do it. The EditText's cursor doesn't appear and the keyboard when appears is not the numeric one. I have the following part of code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="com.android.asminhasdespesas.Meta_1Activity">


    <TextView android:text="Test:"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TableLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <TableRow>


            <EditText
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:inputType="number"
                android:textColor="#000000"
                android:cursorVisible="true"
                android:ems="10"
                android:id="@+id/editTextMeta"
                android:layout_gravity="center_vertical"
                android:layout_weight="1"
                android:focusable="true"
                android:focusableInTouchMode="true" />

            <TextView
                android:text="€"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

        </TableRow>


        <TableRow>

            <Button
                android:id="@+id/buttonNaoColocar"
                android:text="Cancel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="onClick"/>

            <Button
                android:id="@+id/buttonOk"
                android:text="Ok"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:onClick="onClick"/>

        </TableRow>

    </TableLayout>

</LinearLayout>

I tried to solve this situation with "android:cursorVisible="true" or even "android:textColor="#000000", I also tried "android:focusable="true" "android:focusableInTouchMode="true"" but the problem persists, I can't type on EditText.

Can you please help me?

like image 874
porthfind Avatar asked Feb 19 '15 20:02

porthfind


People also ask

What is inputType in android?

The android:inputType attribute allows you to specify various behaviors for the input method. Most importantly, if your text field is intended for basic text input (such as for a text message), you should enable auto spelling correction with the "textAutoCorrect" value.


1 Answers

You probably want something like:

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="number"
        android:textColor="#000000"
        android:cursorVisible="true"
        android:ems="10"
        android:id="@+id/editTextMeta"
        android:layout_gravity="center_vertical"
        android:focusable="true"
        android:focusableInTouchMode="true" />
  • Removed weight (unused)
like image 159
Simas Avatar answered Oct 06 '22 06:10

Simas