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

后端 未结 5 1859
孤城傲影
孤城傲影 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:08

    I found a very easy solution:

    editText.setKeyListener(new DigitsKeyListener(true, true));    
    

    The first true is for whether is signed input, the second true is for decimal.
    Hope that helps

提交回复
热议问题