android - 如何在 EditText 上使用 android:inputType 来指定我的自定义 IME?
问题描述
我的应用程序包含一个自定义 IME(扩展 InputMethodService),我现在想将其指定为我的应用程序中所有 EditTexts 的 IME。
为每个 EditText指定一个android:inputMethod
似乎是一种旧方法,但android:inputMethod
现在已弃用。工具提示说要android:inputType
改用。
我现有的一个 EditText 代码是android:inputType="numberPassword"
,但是当我将其更改为android:inputType=".MyCustomIME"
(或android:inputType="com.example.MyCustomIME"
)时,我在 Android Studio 中收到此错误:
无法解析标志。
那么指定我的 IME 的正确方法是什么(对于单个 EditText 或整个应用程序) - 并且不会丢失我现有的numberPassword
值(因为这决定了我将使用的 IME 子类型)?
我的 IME 在我的清单中定义为:
<service
android:name=".MyCustomIME"
android:label="@string/my_keyboard"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action
android:name="android.view.InputMethod" />
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/keyboard_method" />
</service>
(注意 -android:name="com.example.MyCustomIME"
在上面的<service />
标签中使用没有任何区别。)
解决方案
推荐阅读
- javascript - 如何从 csv-parser 获取数据?
- javascript - 带有 React Native 的 Mercadopago。如何实施?
- mysql - Spring Data JPA 查询:MYSQL TO @QUERY
- constraint-programming - 我可以指定为变量尝试可能值的顺序吗?
- python-3.x - 整个灯都用相同的字典更新
- json - Swift UI 显示来自已解析 json 的数据的问题
- ruby-on-rails - 字符串作为键被转换为符号,在 Rails 中给出不同的行为
- python - 为什么将数据框列转换为类别 dtype 会破坏 groupby 函数
- javascript - 检查数组元素是否具有相同的大小
- javascript - 缓冲区未显示在地图上