我正在开展一个包含用户名和密码的活动 . 我使用了 else 部分中的 AlertDialog.Builder 来显示"wrong password or username"的消息 . 我没有将它连接到任何数据库仅用于测试目的,使用密码和用户名的字符串来比较editText字段的值,在 if 条件中,如果匹配,则将用户带到新的屏幕名称 "NewMenu" . 我的问题是,当登录活动开始(应用程序运行)时,它首先显示所有消息,即 else 部分,我想在单击提交按钮并且密码或用户名错误后显示此消息 . 这是代码
public class Login extends Activity{
private String pass=new String();
private String nam=new String();
private Button log;
private View textreg;
private EditText text1;
private EditText text2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
textreg=(TextView) findViewById(R.id.textRegister);
log=(Button) findViewById(R.id.btnsubmit);
text1=(EditText) findViewById(R.id.txtuname);
如果觉得《java 密码错误提示框_Android“密码或用户名错误”消息框显示错误》对你有帮助,请点赞、收藏,并留下你的观点哦!