how to set input type to be numberdecimal but also allow a “-”

后端 未结 5 1865
孤城傲影
孤城傲影 2021-02-13 15:26

I have set input type to be numberdecimal but also want to populate the editText with a \"-\" programmatically. I can add the text but then I am unable to edit the text as it do

5条回答
  •  情话喂你
    2021-02-13 16:10

    I was able to achieve this behavior by setting digits xml attribute as follows:

    
    

    Setting it up programatically (Set EditText Digits Programmatically):

    weightInput.setKeyListener(DigitsKeyListener.getInstance("0123456789-"));
    

提交回复
热议问题