
http://developer.android.com/guide/topics/text/creating-input-method.html#GeneralDesign
内容如下:
由于可以在设备上安装多个IME,因此为用户提供了一种直接从输入法UI切换到不同IME的方法.
假设我有两个输入方法的源,可以修改它.
我想让用户快速切换它们,并准备为此保留一个按钮.
如何“直接从输入法UI切换到不同的IME”?
解决方法:
从当前输入法切换到上一个输入法是:
//final String LATIN = "com.androID.inputmethod.latin/.LatiniME";// 'this' is an inputMethodServicetry { inputMethodManager imm = (inputMethodManager) this.getSystemService(Context.input_METHOD_SERVICE); final IBinder token = this.getwindow().getwindow().getAttributes().token; //imm.setinputMethod(token, LATIN); imm.switchTolastinputMethod(token);} catch (Throwable t) { // java.lang.NoSuchMethodError if API_level<11 Log.e(TAG,"cannot set the prevIoUs input method:"); t.printstacktrace();}如果要切换到您知道其ID的特定输入法,您可以按照注释掉的行建议.
编辑@pRaNaY在静默编辑中建议单个.getwindow()(单击下面的“编辑”以查看历史记录).我记得它不适用于AndroID 2.3;如果您查阅文档,您将看到第一个调用inputMethodService.getwindow()返回一个Dialog(它不是Window的子类),第二个调用Dialog.getwindow()返回一个Window.没有Dialog.getAttributes(),所以使用单个.getwindow()它甚至不会编译.
总结以上是内存溢出为你收集整理的Android:以编程方式切换到其他IME全部内容,希望文章能够帮你解决Android:以编程方式切换到其他IME所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)