ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

安全知识普及系统2

2022-06-14 20:35:06  阅读:145  来源: 互联网

标签:Toast 普及 String LoginActivity 知识 private 安全 loginInfo new


今天完成了编写了个人页面的内容,并将登录的逻辑实现了

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".activity.MymessageActivity">

    <RelativeLayout
        android:id="@+id/mage1"
        android:layout_width="match_parent"
        android:layout_height="280dp">

        <TextView
            android:id="@+id/text1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="50dp"
            android:text="我的信息:"
            android:textSize="35sp" />

        <TextView
            android:id="@+id/ownmge"
            android:layout_width="370dp"
            android:layout_height="140dp"
            android:layout_below="@+id/text1"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="11dp"
            android:text=""
            android:textSize="35sp" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/mage1"
        android:padding="20dp">

        <TextView
            android:id="@+id/edit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:text="编辑资料"
            android:textSize="35dp" />

        <TextView
            android:id="@+id/Setup"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/edit"
            android:layout_marginTop="20dp"
            android:text="设置"
            android:textSize="35dp" />

        <TextView
            android:id="@+id/about"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/Setup"
            android:layout_marginTop="20dp"
            android:text="关于"
            android:textSize="35dp" />


    </RelativeLayout>

    <RadioGroup
        android:id="@+id/rg_tab"
        android:layout_width="fill_parent"
        android:layout_height="55dp"
        android:gravity="center_vertical"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal">

        <RadioButton
            android:id="@+id/rb_msg"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:button="@null"
            android:checked="true"
            android:gravity="center"
            android:paddingLeft="0dp"
            android:text="收藏" />

        <RadioButton
            android:id="@+id/rb_main"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center"
            android:paddingLeft="0dp"
            android:text="主页" />
        <RadioButton
            android:id="@+id/rb_me"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:button="@null"
            android:gravity="center"
            android:paddingLeft="0dp"
            android:text="我" />
    </RadioGroup>

</RelativeLayout>
public class LoginActivity extends AppCompatActivity {


    private EditText mphonenum;
    private EditText mPassword;
    private Button mButtonLogin;
    private Button mButtonEnroll;
    private Button mButtonUpdate;

    private String phonenum;
    private String password;

    //检验用户是否存在
    private String checkAccount(String phonenum, String userPasswd){
        String loginInfo = "";
        Dao dao = new Dao(LoginActivity.this);
        Log.i("LoginActivity",phonenum+"   密码"+userPasswd);
        String getpsw = dao.queryuserbyphone(phonenum);


        if (getpsw != null){
            if (getpsw.equals(userPasswd)){
                loginInfo = "登录成功";
                Toast.makeText(LoginActivity.this, loginInfo, Toast.LENGTH_SHORT).show();
            }else{
                loginInfo = "密码错误";
                Toast.makeText(LoginActivity.this, loginInfo, Toast.LENGTH_SHORT).show();
                mPassword.requestFocus();
            }
        }else {
            loginInfo = "用户不存在";
            Toast.makeText(LoginActivity.this, loginInfo, Toast.LENGTH_SHORT).show();
            mphonenum.requestFocus();
        }
        return loginInfo;
    }


    private String checkAccount(String phonenum, String userPasswd){
        String loginInfo = "";
        if (phonenum.equals("123456")){
            if (userPasswd.equals("123456")){
                loginInfo = "登录成功";
                Toast.makeText(LoginActivity.this, loginInfo, Toast.LENGTH_SHORT).show();
            }else if (userPasswd.equals("123456")==false){
                loginInfo = "密码错误";
                Toast.makeText(LoginActivity.this, loginInfo, Toast.LENGTH_SHORT).show();
                mPassword.requestFocus();
            }
        }else {
            loginInfo = "用户不存在";
            Toast.makeText(LoginActivity.this, loginInfo, Toast.LENGTH_SHORT).show();
            mphonenum.requestFocus();
    }
        return loginInfo;
    }

    

        mButtonEnroll.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                //跳转到注册界面
                Intent intent = new Intent(LoginActivity.this,EnrollActivity.class);
                startActivity(intent);
            }
        });

        mButtonUpdate.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                //跳转到修改密码界面
                Intent intent = new Intent(LoginActivity.this,UpdateActivity.class);
                startActivity(intent);
            }
        });
    }
}
public class MymessageActivity extends AppCompatActivity {

    private RadioButton mRadioButtonmsg;
    private RadioButton mRadioButtonmain;
    private TextView medit;

    private TextView mownmsg;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mymessage);

        mRadioButtonmsg = (RadioButton) findViewById(R.id.rb_msg);
        mRadioButtonmain = (RadioButton) findViewById(R.id.rb_main);
        medit = findViewById(R.id.edit);

        mownmsg = (TextView) findViewById(R.id.ownmge);

        mownmsg.setText("欢迎您:用户   no.1");



        mRadioButtonmain.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                //跳转到主界面
                Intent intent = new Intent(MymessageActivity.this,MainPageActivity.class);
                startActivity(intent);
            }
        });

        mRadioButtonmsg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //跳转到收藏界面
                Intent intent = new Intent(MymessageActivity.this, ShoucangActivity.class);
                startActivity(intent);
            }
        });

        medit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //跳转到编辑资料页面
                Intent intent = new Intent(MymessageActivity.this, EditActivity.class);
                startActivity(intent);
            }
        });
    }
}

 

标签:Toast,普及,String,LoginActivity,知识,private,安全,loginInfo,new
来源: https://www.cnblogs.com/shiwuzu/p/16376184.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有