简体   繁体   English

SearchView 在数字键盘上使用多个逗号

[英]SearchView use multiple comma with numeric keyboard

I'm trying to get my SearchView to use multiple comma and numbers.我试图让我的SearchView使用多个逗号和数字。 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:所以,基本上我想在下面的键盘上写一些类似2121,4932,4923东西:

Maybe someone has already faced this problem or can just direct me in a relative question也许有人已经遇到过这个问题,或者可以直接向我提出一个相关问题

Thanks in advance, Giacomo.提前致谢,贾科莫。

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,")

在此处输入图片说明

I think you'll need to override the OnKeyDown() listener and filter the input there.我认为您需要覆盖OnKeyDown()侦听器并在那里过滤输入。 You may find this link usefull: example code for OnKeyDown() listener您可能会发现此链接很有用: OnKeyDown() 侦听器的示例代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM