小编Mas*_*eue的帖子

将项目迁移到 androidx 后,EditTextPreference 不显示数字键盘

使用Migrate to AndroidX...Android Studio 提供的功能将我的项目迁移到 AndroidX 并相应地更改了我的依赖项以使所有内容都按预期运行后,我遇到了一个无法解决的小问题。

为了在我的应用程序中设置设备编号,我使用了如下定义的 EditTextPreference,pref_screen.xml它在 PreferenceFragmentCompat 类中设置 setPreferencesFromResource(R.xml.pref_screen, string)

<EditTextPreference
            android:icon="@drawable/ic_perm_device_information_black_24dp"
            android:inputType="number"
            android:key="change_device_id"
            android:maxLines="1"
            android:selectAllOnFocus="true"
            android:singleLine="true"
            android:summary="@string/settings_device_id"
            android:title="@string/pref_title_change_device_id" />
Run Code Online (Sandbox Code Playgroud)

它曾经显示数字键盘来更改值,但在迁移到 AndroidX 后,它继续显示普通键盘,如下图所示。我尝试更改 inputType 并在 xml 中定义小数,但无济于事。迁移到 AndroidX 后是否对键盘的 inputType 设置进行了更改,或者我是否遗漏了一些明显的内容?

android:inputType="numberDecimal"
android:digits="0123456789"
Run Code Online (Sandbox Code Playgroud)

编辑文本首选项键盘

android android-preferences edittextpreference androidx

2
推荐指数
1
解决办法
1603
查看次数