Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过编程从自定义android键盘更改键盘_Android_Ime_Android Input Method - Fatal编程技术网

通过编程从自定义android键盘更改键盘

通过编程从自定义android键盘更改键盘,android,ime,android-input-method,Android,Ime,Android Input Method,我已经创建了一个android自定义键盘。按下按钮后,我希望它将键盘更改回上一个键盘,可以使用InputMethodManager.setInputMethod(IBinder令牌,字符串id) 但是,我无法确定从何处获取令牌-使用getCurrentInputBinding()。getConnectionToken()不起作用 有人知道在哪里可以找到代币吗 谢谢 Ed证明了switchInputMethod(String id)方法起到了治疗作用-不需要该令牌。您通过视图从视图中获取令牌。ge

我已经创建了一个android自定义键盘。按下按钮后,我希望它将键盘更改回上一个键盘,可以使用
InputMethodManager.setInputMethod(IBinder令牌,字符串id)

但是,我无法确定从何处获取令牌-使用
getCurrentInputBinding()。getConnectionToken()
不起作用

有人知道在哪里可以找到代币吗

谢谢


Ed

证明了
switchInputMethod(String id)
方法起到了治疗作用-不需要该令牌。

您通过
视图从视图中获取令牌。getWindowToken()
您可以使用此方法获取令牌并激活上次使用的键盘

 private fun switchToLastKeyboard() {
        try {
            val imm: InputMethodManager =
                this.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
            val token = this.window.window!!.attributes.token
            //imm.setInputMethod(token, LATIN);
            imm.switchToLastInputMethod(token)
        } catch (t: Throwable) { // java.lang.NoSuchMethodError if API_level<11
            Log.i("TAG", "onCreateInputView: Throwable " + t.message)
        }

    }
private fun switchToLastKeyboard(){
试一试{
val imm:InputMethodManager=
此.getSystemService(Context.INPUT\u方法\u服务)作为InputMethodManager
val-token=this.window.window!!.attributes.token
//imm.setInputMethod(标记,拉丁语);
imm.switchToLastInputMethod(令牌)

}捕获(t:可丢弃){//java.lang.NoSuchMethodError如果API_level你在哪里找到这个方法?我不记得我在哪里找到的,但它在扩展InputMethodService的类上可用。我在Google上搜索了这么多,但没有成功获得这个命名方法。好吧,不管它是什么。但是请告诉我你成功地将键盘更改为自定义键盘?我知道了关于这个问题,我有一个问题,就是我想改变键盘的主题,所以我只想知道如何通过编程来做到这一点?有什么想法吗?像这样,如何在自定义键盘中获得以前的键盘ID??