老柳
老柳
  • 发布:2017-01-17 00:59
  • 更新:2018-12-03 22:50
  • 阅读:2296

设备有物理键盘,如何关掉软键盘?

分类:Native.js

我使用的是android版的手持终端,带有物理键盘,在app中需要关掉软键盘,反复试验了以下几种方法,都没有效果,请问如何解决?

static hideSoftInput(){  
    var Context = plus.android.importClass("android.content.Context");  
    var InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");  
    var main = plus.android.runtimeMainActivity();  
    var imm = main.getSystemService(Context.INPUT_METHOD_SERVICE);  
    imm.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS); //InputMethodManager.SHOW_FORCED  
}  

static hideSoftInput2(){      
    let nativeWebview = plus.android.currentWebview();    
    plus.android.importClass(nativeWebview); //android.webkit.WebView类  
    nativeWebview.requestFocus();  
    let InputMethodManager = plus.android.importClass("android.view.inputmethod.InputMethodManager");  
    let main = plus.android.runtimeMainActivity();  
    plus.android.importClass(main);  
    let Context = plus.android.importClass("android.content.Context");  
    let imm = main.getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);  
    imm.hideSoftInputFromWindow(nativeWebview.getWindowToken(), 0);  
}  

static hideSoftInput3(){       
    var runtimeActivity = plus.android.runtimeMainActivity();  
    var w = runtimeActivity.getWindow();  
    plus.android.importClass(w);  
    var params=w.getAttributes();  
    plus.android.importClass(params);  
    var WindowManager = plus.android.importClass('android.view.WindowManager');  
    w.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);   
    params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN;   
}  
2017-01-17 00:59 负责人:无 分享
已邀请:
w***@zhisolution.com

w***@zhisolution.com - 10年IT男

你好,请问这个需求解决了吗?具体如何实现的

老柳

老柳 (作者)

没解决

该问题目前已经被锁定, 无法添加新回复