Forcing edittext to only accept values of: numbers

2019-09-26 03:43发布

this is my xml code


              <EditText
                    android:id="@+id/etSPHr"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="5dp"
                    android:layout_weight="1"
                    android:background="@drawable/myedittext"
                    android:digits="0123456789.+-"
                    android:ems="10"
                    android:inputType="numberDecimal"
                    android:nextFocusForward="@+id/etCYLr"
                    android:paddingLeft="5dp"
                    android:paddingRight="5dp"
                    android:singleLine="true" >

the problem is my keyboard doesnt let me use the plus sign its disabled

1条回答
Lonely孤独者°
2楼-- · 2019-09-26 04:26

Doing

android:inputType="numberDecimal|numberSigned"

should work.

查看更多
登录 后发表回答