查看特定的输入法? [英] View-specific IME?

查看:152
本文介绍了查看特定的输入法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我希望用户能够从一个应用程序定义的字符集输入字符的自定义视图。要做到这一点,据我了解,我需要编写一个输入法服务。用户不仅要安装它,但需要启用在设置>语言和放大器输入法;键盘,然后选择自定义输入法在视图中使用。

I have a custom view for which I want the user to be able to enter characters from an app-defined set of characters. To do this, as I understand it, I need to write an input method service. The user not only needs to install it, but then needs to enable the IME in the Settings > Language & keyboard, and then select the custom IME for use in the view.

这似乎真的疯了。我希望被用于在一个应用程序只是一种观点这个输入法。我不希望它是可用的系统范围或强制用户进行全局设置的更改。

This seems really crazy. I want this IME to be used for just one view in one application. I don't want it to be available system-wide or force the user to make global setting changes.

我能看到的是定义我自己的应用内自定义视图和模拟的输入法(可能是一个全屏幕的)当视图获得焦点的唯一选择。是不是有什么好?

The only alternative I can see is defining my own in-app custom view and simulate an IME (probably a full-screen one) when the view gains focus. Isn't there anything better?

推荐答案

我不认为输入法都被设想为一种任务。其概念是允许用户输入以标准化的方式,因此它可以被用于在多个应用程序从不同的供应商。

I do not think the IMEs are conceived for that kind of task. Their concept is to allow user input in a standardized way so it can be used across multiple applications from different vendors.

我的策略将类似于你在想什么:

My strategy would be similar to what you are thinking:

  • prevent软键盘出现,
  • 拦截菜单按钮键preSS展现自己,而不是,
  • 添加自定义布局(可能是一个的GridView 的TableView RelativeLayout的有底重力)
  • 使用的 OnItemClickListener
  • 发送所需的的KeyEvent s到根查看。如果字符发明的,键codeS 甚至都不需要涉及到的ASCII字符。你只拦截code和使用的意愿。
  • prevent the soft keyboard from appearing,
  • intercept the menu button key press to show your own instead,
  • add a custom layout (probably a GridView or a TableView inside a RelativeLayout with bottom gravity)
  • use an OnItemClickListener
  • send the required KeyEvents to the root View. If the characters are invented, the KeyCodes do not even need to relate to the ASCII character. You just intercept the code and use at will.

抱歉,我不能给你一个选择,你问过,但这种替代似乎并不比创造一个全新的输入法做更多的工作。

Sorry I can't give you an option as you asked, but this alternative does not seem to be much more work than creating a whole new IME.

修改:在阅读了相关的问题,是有意义的使用 android.inputmethodservice.KeyboardView ,而不是重新发明轮子与的GridView

Edit: upon reading the related question, it makes sense to use android.inputmethodservice.KeyboardView instead of reinventing the wheel with the GridView.

这篇关于查看特定的输入法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆