在 phonegap 中隐藏软键盘 android 应用程序启动
Hide soft keyboard android application start up in phonegap
我正在开发 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>
您需要安装keyboard plugin。
cordova plugin add cordova-plugin-keyboard
现在在设备就绪事件中隐藏键盘。
Keyboard.hide();
编辑 1 :-
尝试在 androidmanifest.xml
中添加这一行
android:windowSoftInputMode="stateHidden|adjustPan"
希望这可能有所帮助。
我正在开发 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>
您需要安装keyboard plugin。
cordova plugin add cordova-plugin-keyboard
现在在设备就绪事件中隐藏键盘。
Keyboard.hide();
编辑 1 :-
尝试在 androidmanifest.xml
中添加这一行android:windowSoftInputMode="stateHidden|adjustPan"
希望这可能有所帮助。