我正在处理phonegap应用程序并面临一些小问题并尝试了一切,但没有任何作用..
我已经在Android和Iphone中构建了应用程序,但我只在android中面临问题。软键盘会在启动应用程序时自动显示。
下面是我的HTML代码: -
<body>
<div id="page-transitions">
<div class="header header-logo-center header-dark">
<!-- <a href="#" class="header-icon header-icon-1 hamburger-animated open-sidebar-left"></a> -->
<a href="index.html" class="header-logo"></a>
<!-- <a href="#" class="header-icon header-icon-4 open-sidebar-right"><i class="ion-ios-email-outline"></i></a> -->
</div>
<div id="page-content" class="page-content">
<div id="page-content-scroll">
<!--Enables this element to be scrolled -->
<div class="page-fullscreen vertical-bg-3">
<div class="page-fullscreen-content">
<div class="pageapp-login">
<div class="pageapp-login-input animate-fade">
<i class="login-icon ion-person"></i>
<input id="username" type="email" value="Username" onfocus="if (this.value=='Username') this.value = ''" onblur="if (this.value=='') this.value = 'Username'">
</div>
<div class="pageapp-login-input animate-fade animate-delay-100">
<i class="login-icon ion-asterisk"></i>
<input id="password" type="password" value="Password" onfocus="if (this.value=='Password') this.value = ''" onblur="if (this.value=='') this.value = 'Password'">
</div>
<div class="pageapp-login-links">
<!-- <a href="#" class="page-login-forgot"><i class="ion-ios-eye"></i>Forgot Credentials</a> -->
<a href="page-register.html" target="_self" class="page-login-create animate-right">Create Account<i class="ion-person"></i></a>
<div class="clear"></div>
</div>
<button id="btnSubmit" class="button button-green button-icon button-full half-top full-bottom animate-zoom"><i class="ion-ios-arrow-thin-right"></i>Login</button>
</div>
</div>
<div class="overlay dark-overlay"></div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
}).on('deviceready', function () {
document.addEventListener("deviceready",
checkExistingSession, false);
});
js代码将加载到设备就绪事件并重定向到另一个页面
function checkExistingSession() {
var userName = localStorage.getItem("username");
var password = localStorage.getItem("password");
var deviceType = localStorage.getItem("deviceType");
var deviceToken = localStorage.getItem("deviceToken");
var parameter = {
"username": userName,
"password": password,
"deviceType": deviceType,
"deviceToken": deviceToken
}
if (userName != null && password != null) {
$.ajax({
url: api_baseUrl + 'login',
type: "post",
data: JSON.stringify(parameter),
dataType: "json",
success: function (response) {
// Inserting html into the result div on success
if (response !== null && response.status === 1) {
window.location = "dashboard.html";
}
else {
window.location = "index.html";
return false;
}
}
});
}
}
</script>
</body>
答案 0 :(得分:1)
您需要安装keyboard plugin。
cordova plugin add cordova-plugin-keyboard
现在,在设备就绪事件中隐藏键盘。
Keyboard.hide();
编辑1: -
尝试在androidmanifest.xml中添加此行
android:windowSoftInputMode="stateHidden|adjustPan"
希望这可能有所帮助。