Android studio realizes QQ registration, login and jump between friend lists

This project mainly includes three interfaces: registration, login and friend list, and jump between them. The friends list interface is designed in detail, including friends' avatars and message content. The user first clicks the registration button to enter the registration interface. After entering the account and password, click registration to jump to the login interface. At this time, the account and password are also transmitted. Click the login button to enter the friends list interface. At this time, the user name is also transmitted.

The overall layout is a relative layout. The upper ImageView is the avatar box, and the lower LinearLayout displays the account textview and EditText; Then there is a LinearLayout, which contains the textview and EditText of the password. At the bottom are two buttons, one is login and the other is registration, which is the same width as the parent layout.

The outermost layer is relativelayout, the top is a textview of "new user registration", and the bottom is a LinearLayout, which displays the account textview and the input box EditText; Then there is a LinearLayout, which is the textview of the password and the input box EditText. At the bottom is the registered button, onclick = "click".

The outermost layer is the LinearLayout layout, which is arranged vertically. First, there is a LinearLayout at the top, which contains an ImageView avatar and a textview text box to receive the user's account when logging in and display it here. Below is a textview that displays a "friend list", followed by a listview list that displays friend information.

Log in to the listener bound to the button, set the intention to jump, and click to jump from the current main interface to the friends list interface.

btn_log.setOnClickListener(new View.OnClickListener() {//匿名内部类方式实现按钮点击事件
            @Override
            public void onClick(View v) {//传递数据
                Intent intent=new Intent(MainActivity.this,friend_list_Activity.class);//创建Intent对象,启动Activity02
                //将数据存入Intent对象
                intent.putExtra("name",et_name.getText().toString().trim());
                startActivity(intent);
            }
        });
        btn_reg.setOnClickListener(this);

Register the listener bound to the button, create intent, and click to jump to the registration interface.

public void onClick(View view){
        switch(view.getId()){
            case R.id.btn_register:
            Intent intent=new Intent(this,register_Activity.class);
            startActivityForResult(intent,1);//返回请求结果,请求码为1
        }
    }

The registration button in the registration interface is implemented by clicking to create the intention and pass the value.

public void click(View view) {
        Toast.makeText(this, "注册成功!", Toast.LENGTH_SHORT).show();
        Intent intent = new Intent();
        intent.putExtra("name", reg_name.getText().toString().trim());
        intent.putExtra("password", reg_password.getText().toString().trim());
        setResult(1, intent);
        finish();
    }

1. The main interface is displayed as login interface by default.

This QQ page Jump project mainly tests students' use of listview and intent. They should be familiar with the jump and value transfer between multiple pages. These knowledge points will be often used in Android projects in the future. Therefore, we hope you can master the use of the above knowledge points to facilitate subsequent development projects.

Students who need source learning can pay attention to my WeChat official account. Reply: QQ page skip, you can get source code, and many Android projects waiting for you to learn.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>