简体   繁体   English

Java ADK登录应用程序不起作用

[英]Java ADK Login application not working

So I'm super new to developing applications for Android, and have never touched Java before now. 因此,对于开发适用于Android的应用程序来说,我是一个超级新手,并且从未接触过Java。 I'm trying to make an extremely simple app where you are shown a login screen, you enter a password (which is static and localized, I'm not at the point of using auth servers yet). 我正在尝试制作一个非常简单的应用程序,在该应用程序中会看到一个登录屏幕,输入一个密码(该密码是静态的和本地化的,我还没有使用身份验证服务器)。

The OnClick callback compares the text currently in the EditText to the preset passcode (which is "1234") and decides whether to change to the activity that follows or to deny access. OnClick回调将EditText当前的文本与预设密码(“ 1234”)进行比较,并决定是更改为随后的活动还是拒绝访问。

When I run the app it works perfectly with no errors, except that when I tap the "Log In" button with 1234 in the EditText , I get no response. 当我运行该应用程序时,它运行正常,没有任何错误,除了当我在EditText中用1234轻按“登录”按钮时,没有任何反应。 Nothing happens. 什么都没发生。 Very frustrating. 非常沮丧。 Please help and explain any corrections you make to my code, I'm eager to learn! 请帮助并解释您对我的代码所做的任何更正,我很想学习!

The class file for my activity. 我的活动的课程文件。

我的活动的课程文件

There are multiple issues that I can see in your code: 我可以在您的代码中看到多个问题:

  1. Why you are initializing your edittext twice, remove the second one in OnClickListener. 为什么要初始化两次编辑文本,请在OnClickListener中删除第二个。
  2. Calling setContentView is not enough to change the activity, you have to create another activity class and change the screen with the help of Intent. 调用setContentView不足以更改活动,您必须创建另一个活动类并在Intent的帮助下更改屏幕。 if you don'y know about Intent check this: 如果您不了解Intent,请检查以下内容:

https://developer.android.com/training/basics/firstapp/starting-activity.html https://developer.android.com/training/basics/firstapp/starting-activity.html

  1. To compare String there is a predefined method just use that like this: 要比较String,有一个预定义的方法,就像这样使用:

     if(pinText.equalsIgnoreCase("1234")){ // Call your intent here. } 

    I'll suggest to find a good tutorial series of Android Development on internet and start learning from there. 我建议在互联网上找到一个不错的Android开发教程系列,并从那里开始学习。 I'll help you to understand the things in better way. 我会帮助您更好地理解事物。

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

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