android - 在 ActionBar 中将数字输入类型设置为 SearchView

标签 android input android-actionbar searchable keypad

我没有设法将数字输入类型设置为我的 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/

相关文章:

android - 将值传递给 ViewPager fragment

android - 如何从 url 中获取大图像?

java - 将已安装的小部件添加到 Android Activity

c - 将输入发送到在 Windows 计算机上使用 C 中的 createprocess() 创建的进程

android - 在 Android [Titanium] 的标题中隐藏默认的应用程序图标和应用程序名称

java - 使用 ActionBar 导航返回上一个 Activity

android - Android 支持库中的 ActionBar#setDefaultDisplayHomeAsUpEnabled 是什么?

Android 应用程序启动图标大小

android - 如何使用 InputConnectionWrapper?

java处理命令行输入