昨天做完了验证码,那今天就把他加入到帐号密码之中
首先要先建立一个imageview来存放验证码,并把它设置为不可见
<LinearLayout
android:id="@+id/code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:visibility="invisible">
<ImageView
android:id="@+id/identifyingcode_image"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
接着判断帐号密码与验证码的逻辑
if (password.getText().toString().equals(userpassword) &&
(account.getText().toString().equals(usercellphone) ||
account.getText().toString().equals(useremail))){
if(code.getVisibility()==View.VISIBLE) {
if (usercode.getText().toString().toLowerCase().equals(realCode)) {
if(checkbox.isChecked()){
SharedPreferences remember = getSharedPreferences("remember", MODE_PRIVATE);
remember.edit().putString("account", acc).putString("password", pass).putBoolean("ischeck",true).commit();
Bundle bundle = new Bundle();
bundle.putString("page", "1");
start(FragmentActivity.class, bundle, true);
}
else{
SharedPreferences remember=getSharedPreferences("remember",MODE_PRIVATE);
remember.edit().clear().commit();
Bundle bundle=new Bundle();
bundle.putString("page","1");
start(FragmentActivity.class,bundle,true);
}
}
else{
Toast.makeText(this,"验证码错误",Toast.LENGTH_SHORT).show();
}
}
else{
if (checkbox.isChecked()) {
SharedPreferences remember = getSharedPreferences("remember", MODE_PRIVATE);
remember.edit().putString("account", acc).putString("password", pass).putBoolean("ischeck",true).commit();
Bundle bundle = new Bundle();
bundle.putString("page", "1");
start(FragmentActivity.class, bundle, true);
}
else{
SharedPreferences remember = getSharedPreferences("remember", MODE_PRIVATE);
remember.edit().clear().commit();
Bundle bundle = new Bundle();
bundle.putString("page", "1");
start(FragmentActivity.class, bundle, true);
}
}
}
else{
code.setVisibility(View.VISIBLE);
visible.setVisibility(View.VISIBLE);
Toast.makeText(this, "帐号密码错误", Toast.LENGTH_SHORT).show();
}
}
成果如下
接着帐号密码错误的时候
<<: [第二十四只羊] 迷雾森林舞会XVIII 游戏角色设定again_final_final
简短自我介绍 大家好!我是Marshal,目前还是一位在校大学生,就读资讯相关科系。 为什麽会想选这...
昨天有提到人变成主角,食物变成配角,大概就是像这样 广义上来说,吃到饱是从红亭开始的,但是我那时候都...
昨天,提供了一种CSS命名的方法, 今天,我们再来看看有什麽要避免的CSS命名呢? 避免直接把颜色放...
先简单回顾一下,今天预计分析的题目: Valid Parentheses 昨天问到,如果 ([)] ...
阿修的说文解字 API 的全名是 Application Programming Interface...