Forcing edittext to only accept values of: numbers, decimals, plus, and minus signs [closed]

让人想犯罪 __ 提交于 2019-12-13 10:01:45

问题


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:


Doing

android:inputType="numberDecimal|numberSigned"

should work.



来源:https://stackoverflow.com/questions/14488060/forcing-edittext-to-only-accept-values-of-numbers-decimals-plus-and-minus-si

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!