我使用Cordova v5.3.3,Html5,Angaular JS,Bootstrap v3.1.1在移动应用程序中工作。在该应用程序中,我有一个弹出textarea组合的角度js自定义指令和bootstrap。 对于使用shown.bs.modal事件自动聚焦弹出窗口。一旦textarea聚焦,键盘就会自动打开以进行输入,其中包含笑脸/情绪。我想避免在textarea上输入笑脸/情感有没有办法做到这一点? 我尝试了以下方法/解决方案,但这不起作用
1. onkeypress and ng-keypress event is not working android Tab(Samsung Galaxy Tab SM-T231 Android OS 4.4.2)
2. onkeyup and onkeydown with Regex replace not working because the event get fired once the character is typed
3. Tried some keyboard plugins but not helpful.
3.1 https://github.com/phonostar/PhoneGap-SoftKeyboard
3.2 https://github.com/macdonst/phonegap-plugins/tree/master/Android/SoftKeyboard
3.3 https://github.com/driftyco/ionic-plugin-keyboard
4. Try to hide softkeyboard using below configuration in config.xml and AndroidManifest.xml file but not working.
<preference name="android-windowSoftInputMode" value="stateHidden"/>
<preference name="fullscreen" value="false" /> ----in config.xml
In AndroidManifest.xml file
<activity android:windowSoftInputMode="stateAlwaysHidden" ... > ... </activity>
5. In MainActivity.java class i was tried some approaches was listed blow
The below code is written inside the onCreate method.
5.1
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED);
5.2
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getContentView().getWindowToken(), 0);
5.3 Created one Javascript interface and try to fire the event from javascript
class JSInterface {
@JavascriptInterface
public void hideKeyboard() {
runOnUiThread(new Runnable() {
public void run() {
try {
InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext().getSystemService(Service.INPUT_METHOD_SERVICE);
InputMethodManager inputMethodManager = (InputMethodManager) cordova.getActivity().getApplicationContext().getSystemService(Service.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(MainActivity.this.getCurrentFocus().getWindowToken(), 0);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
不幸的是,这对我也没有帮助。任何人都面临这个问题吗?有人帮我解决这个问题吗?