Javascript Android和BlackBerry中的键盘未显示在元素焦点上
在应用程序启动时,我需要键盘出现在屏幕上 我可以在iOS中实现这一点,在iOS中,我将焦点设置在文本字段上,键盘就会出现。然而,在Android和BlackBerry中,即使文本字段变得集中,键盘也不会显示出来 我已使用以下代码设置焦点:Javascript Android和BlackBerry中的键盘未显示在元素焦点上,javascript,android,ios,blackberry,ibm-mobilefirst,Javascript,Android,Ios,Blackberry,Ibm Mobilefirst,在应用程序启动时,我需要键盘出现在屏幕上 我可以在iOS中实现这一点,在iOS中,我将焦点设置在文本字段上,键盘就会出现。然而,在Android和BlackBerry中,即使文本字段变得集中,键盘也不会显示出来 我已使用以下代码设置焦点: setTimeout(function(){ document.getElementById("mglTxtEmailAddr").focus(); }, 200); Android 假设您使用的是Worklight 6.2或更高版本,您可以使用以下
setTimeout(function(){
document.getElementById("mglTxtEmailAddr").focus();
}, 200);
Android
假设您使用的是Worklight 6.2或更高版本,您可以使用以下代码在Android的焦点上显示键盘
Javascript:
document.getElementById('mglTxtEmailAddr').addEventListener('focus', function(){
WL.App.sendActionToNative('showKeyboard',{});
});
setTimeout(function(){
document.getElementById("mglTxtEmailAddr").focus();
}, 200);
WL.getInstance().addActionReceiver(new WLActionReceiver(){
@Override
public void onActionReceived(String action, JSONObject arg1) {
if("showKeyboard".equals(action)) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
}
}
});
在Worklight Studio生成的活动类中,在onCreate函数的末尾添加以下操作接收器
YourActivity.java:
document.getElementById('mglTxtEmailAddr').addEventListener('focus', function(){
WL.App.sendActionToNative('showKeyboard',{});
});
setTimeout(function(){
document.getElementById("mglTxtEmailAddr").focus();
}, 200);
WL.getInstance().addActionReceiver(new WLActionReceiver(){
@Override
public void onActionReceived(String action, JSONObject arg1) {
if("showKeyboard".equals(action)) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
}
}
});
iOS
对于AppDelegate类中的iOS,在WLinitDidComplete中成功地添加以下代码:
[cordovaViewController.webView setKeyboardDisplayRequiresUserAction:NO];
Android
假设您使用的是Worklight 6.2或更高版本,您可以使用以下代码在Android的焦点上显示键盘
Javascript:
document.getElementById('mglTxtEmailAddr').addEventListener('focus', function(){
WL.App.sendActionToNative('showKeyboard',{});
});
setTimeout(function(){
document.getElementById("mglTxtEmailAddr").focus();
}, 200);
WL.getInstance().addActionReceiver(new WLActionReceiver(){
@Override
public void onActionReceived(String action, JSONObject arg1) {
if("showKeyboard".equals(action)) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
}
}
});
在Worklight Studio生成的活动类中,在onCreate函数的末尾添加以下操作接收器
YourActivity.java:
document.getElementById('mglTxtEmailAddr').addEventListener('focus', function(){
WL.App.sendActionToNative('showKeyboard',{});
});
setTimeout(function(){
document.getElementById("mglTxtEmailAddr").focus();
}, 200);
WL.getInstance().addActionReceiver(new WLActionReceiver(){
@Override
public void onActionReceived(String action, JSONObject arg1) {
if("showKeyboard".equals(action)) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
}
}
});
iOS
对于AppDelegate类中的iOS,在WLinitDidComplete中成功地添加以下代码:
[cordovaViewController.webView setKeyboardDisplayRequiresUserAction:NO];
Android
假设您使用的是Worklight 6.2或更高版本,您可以使用以下代码在Android的焦点上显示键盘
Javascript:
document.getElementById('mglTxtEmailAddr').addEventListener('focus', function(){
WL.App.sendActionToNative('showKeyboard',{});
});
setTimeout(function(){
document.getElementById("mglTxtEmailAddr").focus();
}, 200);
WL.getInstance().addActionReceiver(new WLActionReceiver(){
@Override
public void onActionReceived(String action, JSONObject arg1) {
if("showKeyboard".equals(action)) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
}
}
});
在Worklight Studio生成的活动类中,在onCreate函数的末尾添加以下操作接收器
YourActivity.java:
document.getElementById('mglTxtEmailAddr').addEventListener('focus', function(){
WL.App.sendActionToNative('showKeyboard',{});
});
setTimeout(function(){
document.getElementById("mglTxtEmailAddr").focus();
}, 200);
WL.getInstance().addActionReceiver(new WLActionReceiver(){
@Override
public void onActionReceived(String action, JSONObject arg1) {
if("showKeyboard".equals(action)) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
}
}
});
iOS
对于AppDelegate类中的iOS,在WLinitDidComplete中成功地添加以下代码:
[cordovaViewController.webView setKeyboardDisplayRequiresUserAction:NO];
Android
假设您使用的是Worklight 6.2或更高版本,您可以使用以下代码在Android的焦点上显示键盘
Javascript:
document.getElementById('mglTxtEmailAddr').addEventListener('focus', function(){
WL.App.sendActionToNative('showKeyboard',{});
});
setTimeout(function(){
document.getElementById("mglTxtEmailAddr").focus();
}, 200);
WL.getInstance().addActionReceiver(new WLActionReceiver(){
@Override
public void onActionReceived(String action, JSONObject arg1) {
if("showKeyboard".equals(action)) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
}
}
});
在Worklight Studio生成的活动类中,在onCreate函数的末尾添加以下操作接收器
YourActivity.java:
document.getElementById('mglTxtEmailAddr').addEventListener('focus', function(){
WL.App.sendActionToNative('showKeyboard',{});
});
setTimeout(function(){
document.getElementById("mglTxtEmailAddr").focus();
}, 200);
WL.getInstance().addActionReceiver(new WLActionReceiver(){
@Override
public void onActionReceived(String action, JSONObject arg1) {
if("showKeyboard".equals(action)) {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
}
}
});
iOS
对于AppDelegate类中的iOS,在WLinitDidComplete中成功地添加以下代码:
[cordovaViewController.webView setKeyboardDisplayRequiresUserAction:NO];
这段代码在iOS模拟器中也不起作用。@IdanAdar:好的,但我已经在设备上测试过了。它工作得很好。你能帮我实现我的目标吗?我已经尝试了一段时间了。尚未成功。@DhavalParmar您正在使用哪个版本的Worklight?@Idandar我添加了一个解决方案,假设使用WL 6.2及更新版本。此代码在iOS模拟器中也不起作用。@Idandar:好的,但我已经在设备上测试过,它工作正常。您能帮我实现在首次启动键盘时安装键盘的目标吗我已经试了一段时间了。尚未成功。@DhavalParmar您正在使用哪个版本的Worklight?@Idandar我添加了一个解决方案,假设使用WL 6.2及更新版本。此代码在iOS模拟器中也不起作用。@Idandar:好的,但我已经在设备上测试过,它工作正常。您能帮我实现在首次启动键盘时安装键盘的目标吗我已经试了一段时间了。尚未成功。@DhavalParmar您正在使用哪个版本的Worklight?@Idandar我添加了一个解决方案,假设使用WL 6.2及更新版本。此代码在iOS模拟器中也不起作用。@Idandar:好的,但我已经在设备上测试过,它工作正常。您能帮我实现在首次启动键盘时安装键盘的目标吗我已经试了一段时间了。尚未成功。@DhavalParmar您使用的Worklight版本是什么?@IdanAdar我添加了一个解决方案,假设您使用的是WL 6.2及更新版本。哦,非常好!)现在对iOS也这样做。唯一的例外是黑莓,它不支持SendAction。大+1!哦,非常好!:)现在对iOS也这样做。唯一的例外是黑莓,它不支持SendAction。大+1!哦,非常好!:)现在对iOS也这样做。唯一的例外是黑莓,它不支持SendAction。大+1!哦,非常好!:)现在对iOS也这样做。唯一的例外是黑莓,它不支持SendAction。大+1!