简体   繁体   English

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

[英]Phonegap: How to show configuration screen only once

I have started work on Phonegap and it is very hard for Native App developer to go for Hybrid. 我已经开始从事Phonegap的工作,对于Native App开发人员而言,很难使用Hybrid。

Just want to know that how I can show configuration screen only once in Phonegap. 只想知道如何在Phonegap中仅显示一次配置屏幕。 Below is the screenshot. 下面是屏幕截图。 I just want to show it only when user runs an app first time, and not again and again whenever user launches an app and saves IP address. 我只想仅在用户第一次运行应用程序时显示它,而不是在用户启动应用程序并保存IP地址时一次又一次显示它。

eConfig屏幕

The problem here is that, whenever I press back button of device, this screen gets display. 这里的问题是,每当我按设备的后退按钮时,都会显示此屏幕。

Here is my HTML: 这是我的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>

What Cordova Plugin I need? 我需要什么Cordova插件

NOTE: I am using Jquery Mobile and Cordova SQLite Plugin for data storage. 注意:我正在使用Jquery Mobile和Cordova SQLite插件进行数据存储。 And my app is Single Page Architecture. 我的应用是单页体系结构。

Thanks in Advance! 提前致谢!

Please let me know if not clear. 如果不清楚,请通知我。

You have to write this line in device ready function. 您必须在设备就绪功能中编写此行。

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

function onBackKeyDown(){

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

Use localStorage . 使用localStorage Save a simple string with key and check whether there is a particular value against key or not in deviceready function. 用key保存一个简单的字符串,并检查deviceready函数中是否有针对key的特定值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM