我没有设法将数字输入类型设置为我的 ActionBar 中的 SearchView。我的 res/xml 文件夹中有以下 searchable.xml 文件:
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:inputType="number"
android:label="@string/app_name"
android:hint="@string/search_hint">
</searchable>
然后我将可搜索配置设置为 SearchView,如下所示:
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
search_hint 设置正确,但行 android:inputType="number" 似乎没有效果,即数字小键盘没有出现。
有人有解决办法吗?
最佳答案
将此添加到您的 searchable.xml 布局文件中:
android:numeric="decimal"
或者如果没有用就试试,
android:inputType="phone"
让我知道发生了什么。
关于android - 在 ActionBar 中将数字输入类型设置为 SearchView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8293552/