javaandroidsearchviewandroid-menuandroid-inputtype

SearchView use multiple comma with numeric keyboard


I'm trying to get my SearchView to use multiple comma and numbers. Unfortunately I'm stuck with be able to use only one comma using the following settings:

SearchView searchView = (SearchView) menuItem.getActionView();
searchView.setInputType(InputType.TYPE_CLASS_NUMBER + InputType.TYPE_NUMBER_VARIATION_NORMAL);

Another important point is to be able to use the numeric keyboard.

So, basically i would like to write something like 2121,4932,4923 in the following keyboard:

Maybe someone has already faced this problem or can just direct me in a relative question

Thanks in advance, Giacomo.


Solution

  • val searchView: SearchView = search.actionView as SearchView
    val editText = searchView.findViewById<EditText>(R.id.search_src_text)
    editText.inputType = InputType.TYPE_CLASS_NUMBER + InputType.TYPE_NUMBER_FLAG_DECIMAL
    editText.keyListener = DigitsKeyListener.getInstance("0123456789,")
    

    enter image description here