Phonegap:如何仅显示一次配置屏幕

时间:2015-02-04 06:24:50

标签: android ios html5 cordova jquery-mobile

我已经开始使用Phonegap了,Native App开发人员很难选择Hybrid。

只想知道如何在Phonegap中显示配置屏幕一次。以下是截图。我只是想在用户第一次运行应用程序时显示它,而不是每当用户启动应用程序并保存IP地址时一次又一次地显示它。

eConfig Screen

这里的问题是,每当我按下设备的后退按钮时,此屏幕就会显示。

这是我的HTML:

<body>

<div data-role="page" id="pageConfig"> // This Div needs to show only first time

    <div class="ui-content" data-role="main">
        <h3>Configurations</h3>

        <label for="ipText">IP Address:</label>
        <input type="url" id="ipText" name="ipText" />
        <a href="#" class="ui-btn ui-btn-b ui-corner-all mc-top-margin-1-5" onclick="saveConfigs()">Save</a>
    </div>

</div>

<div data-role="page" id="pgLgn">

    <div data-role="main" class="ui-content">
        <form id="form1" class="validate">

            <div class="ui-field-contain">
                <label for="usrNme">Username:</label>
                <input type="text" name="usrNme" id="usrNme" placeholder="Username" data-clear-btn="true" data-theme="d" class="required" />
            </div>

            <div class="ui-field-contain">
                <label for="pswrd">Password:</label>
                <input type="password" name="pswrd" id="pswrd" placeholder="Password" data-clear-btn="true" data-theme="d" class="required" />
            </div>

            <div class="ui-field-contain">
                <input type="checkbox" id="chbx-0" class="custom" data-inline="true" />
                <label for="chbx-0">Remember me</label>
            </div>

            <input type="submit" data-inline="true" value="Login" id="btnLogin" data-shadow="false" data-theme="a" onclick="OnLoginClick()"/>
            <input type="reset" data-inline="true" value="Reset" data-shadow="false" />

        </form>
    </div>
</div>
</body>

我需要什么 Cordova插件

注意:我正在使用Jquery Mobile和Cordova SQLite插件进行数据存储。我的应用程序是单页架构。

提前致谢!

如果不清楚,请告诉我。

1 个答案:

答案 0 :(得分:2)

您必须在设备就绪功能中写入此行。

document.addEventListener("backbutton",onBackKeyDown,false);

function onBackKeyDown(){

 if($.mobile.activePage.attr("id") == "pgLgn"){
            navigator.app.exitApp();
        }
        else{
            navigator.app.backHistory();
}
}

使用localStorage。使用键保存一个简单的字符串,并检查deviceready函数中是否存在特定的键值。