java - 关于强制切换输入法
伊谢尔伦
伊谢尔伦 2017-04-17 17:46:02
0
1
273
    inputmethodserver = new InputMethodService();
    button = (Button) findViewById(R.id.button1);
    button.setOnClickListener(new OnClickListener() {
        
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            inputmethodserver.switchInputMethod("com.google.android.inputmethod.pinyin.PinyinIME");
           }
    });
}

在调用switchInputMethod方法的时候报错null指针 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.inputmethod.InputMethodManager.setInputMethod(android.os.IBinder, java.lang.String)' on a null object reference
看API实际上就是调用了InputMethodManager.SetInputMethod(IBinder token,String id)报错空指针是不是就是那个token的问题啊 如果是这样的话不是又回到了需要获取token这个参数了吗 API中IBinder这个是在InputMethodImpl这个类中的attachToken方法中被赋值所以调用 switchInputMethod方法以前还是要获得IBinder?那和直接调用SetInputMethod方法不是一样了吗

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

répondre à tous(1)
阿神

http://stackoverflow.com/ques... Android并不允许软件切换都指定输入法

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!