Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to enter minus sign for EditText

I have following EditText element, when the keyboard shows up to enter value here there is a - sign shown there but nothing happens when you click it? can anyone tell me why.

<EditText
    android:id="@+id/kernelb11"
    android:layout_width="@dimen/matrixBoxWidthHeight"
    android:layout_height="@dimen/matrixBoxWidthHeight"
    android:layout_below="@+id/textViewb"
    android:layout_margin="@dimen/marginOne"
    android:background="@color/white1"
    android:gravity="center"
    android:inputType="number"
    android:maxLength="2"
    android:text="0" >
like image 727
Maven Avatar asked Nov 06 '13 11:11

Maven


3 Answers

android:inputType="numberSigned"

and it should work.

like image 66
Carnal Avatar answered Nov 02 '22 23:11

Carnal


if input type as number then - sign will not be accepted, so you need to use input type as numberSigned like

android:inputType="numberSigned"

or

android:inputType="text"
android:digits="0123456789-"

inside EditText

like image 20
krishna Avatar answered Nov 03 '22 01:11

krishna


android:inputType="number"

A numeric only field. Corresponds to TYPE_CLASS_NUMBER | TYPE_NUMBER_VARIATION_NORMAL.

use

android:inputType="numberSigned"

Can be combined with number and its other options to allow a signed number. Corresponds to TYPE_CLASS_NUMBER | TYPE_NUMBER_FLAG_SIGNED.

Docs

like image 35
Tarsem Singh Avatar answered Nov 03 '22 01:11

Tarsem Singh