简体   繁体   English

应用启动后需要密码

[英]Require password after app start

currently developing an android application. 目前正在开发一个android应用程序。 when application starts up I want it to require a user name and password to enter. 当应用程序启动时,我希望它要求输入用户名和密码。 haven't had any luck searching. 没有运气搜索。 currently have main layout with just enter button and an edit text for password. 当前具有主布局,只需输入按钮和密码的编辑文本即可。 couldn't post image of layout here is code. 无法在此处发布布局图片是代码。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/welcome" />
<Button
    android:id="@+id/btnEnter"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/enter"></Button>
<EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:hint="@string/signPass"
    android:gravity="center_horizontal" 
    android:inputType="textPassword" >

    <requestFocus /> 
</EditText>
<Button
    android:id="@+id/btnInitiate"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/initiate"></Button>

</LinearLayout>

You can take in the user input for username and password and compare it to database records. 您可以接受用户输入的用户名和密码,并将其与数据库记录进行比较。 You can then handle the result via an if-else statement, if there's a positive match, then you can proceed by calling another activity. 然后,您可以通过if-else语句处理结果,如果存在正匹配,则可以通过调用另一个活动来继续。 Otherwise, you show a toast to notify the user about the mismatch. 否则,您将举杯祝酒,以告知用户不匹配的情况。

I strongly suggest you go over basic Android tutorials and come back when you stumble upon other problems. 我强烈建议您阅读基本的Android教程,然后在遇到其他问题时再回来。

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

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