How to realize the registration page to jump to the login page by Android Studio
Today, I would like to share with you how to achieve Android Studio registration page jump login page of the relevant knowledge, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you have something to gain after reading this article, let's take a look at it.
User registration interface
User login interface
Java code to achieve jump
Package com.example.myapplication1;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.CheckBox;import android.widget.CompoundButton;import android.widget.EditText;import android.widget.RadioButton;import android.widget.RadioGroup;import android.widget.TextView;import androidx.appcompat.app.ActionBar;import androidx.appcompat.app.AppCompatActivity;public class MainActivity extends AppCompatActivity implements View.OnClickListener,RadioGroup.OnCheckedChangeListener, CompoundButton.OnCheckedChangeListener {private Button zc / the variable RadioGroup rg;// that declares the registration button declares the variable RadioButton rb1,rb2;// of the radio group declares radio 1, the variable CheckBox cb1,cb2,cb3;// of radio 2 declares the check box 1, and the variable EditText et1,et2; declares the variable EditText et1,et2; of input text box 1, the variable of TextView tv,txtage,txtall;// declaration of 2, the variable of the result text @ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState) SetContentView (R.layout.activity_main); / / shielded system comes with ActionBar actionBar = getSupportActionBar (); if (actionBar! = null) {actionBar.hide ();} zc=findViewById (R.id.button); / / find the registration button id zc.setOnClickListener (this); / / install the listener rg=findViewById (R.id.rg) to the registration button / / find the radio group control id rg.setOnCheckedChangeListener (this); / / install the listener rb1=findViewById (R.id.rb1) for the radio group; / / find the radio control 1id rb1.setOnCheckedChangeListener (this); / / install the listener rb2=findViewById (R.id.rb2) for radio control 1; / / find the radio control 2id rb2.setOnCheckedChangeListener (this) / / install listeners for radio control 2 / / txtage= (TextView) findViewById (R.id.age); cb1=findViewById (R.id.cb1); / / find check box 1 control id cb1.setOnCheckedChangeListener (this); / / install listener cb2=findViewById (R.id.cb2) for check box control 1; / / find check box 2 control id cb2.setOnCheckedChangeListener (this) / / install listener cb3=findViewById (R.id.cb3) for check box control 2; / / find check box 3 control id cb3.setOnCheckedChangeListener (this); / / install listener et1=findViewById (R.id.et1) for check box control 3; / / find input box 1 control id et2=findViewById (R.id.et2); / find input box 2 control id tv=findViewById (R.id.tv) / / find input box 2 control id} / / implement option button group interaction @ Override public void onCheckedChanged (RadioGroup group, int checkedId) {switch (checkedId) {case R.id.rb1: System.out.println (rb1.getText (). ToString ()); break Case R.id.rb2: System.out.println (rb2.getText (). ToString ()); break }} / / implement check box interaction @ Override / / CompoundButton selected or unselected button public void onCheckedChanged (CompoundButton CompoundButton Boolean b) {switch (CompoundButton.getId ()) / / get the selected or unchecked button id {case R.id.cb1: / / check box 1id if (b==true) / / determine whether check box 1 is true System.out.println (cb1.getText (). ToString ()) / / if it is true, the output of the check box button is to get the text (text attribute text string corresponding to cb1) string break; case R.id.cb2: if (b==true) System.out.println (cb2.getText (). ToString ()); break Case R.id.cb3: if (b==true) System.out.println (cb3.getText () .toString ()); break;}} / / Registration button @ Override public void onClick (View view) {String strname=et1.getText () .toString () / / get the user name (ID binding user name) String strPassword=et2.getText () .toString (); / / get the password (ID binding password) / / int age; CharSequence str= ""; if (rb1.isChecked ()) str=rb1.getText () If (rb2.isChecked ()) str=rb2.getText (); String str1= ""; if (cb1.isChecked ()) str1=str1+ "\ n" + cb1.getText (); if (cb2.isChecked ()) str1=str1+ "\ n" + cb2.getText (); if (cb3.isChecked ()) str1=str1+ "\ n" + cb3.getText () / / if (strname.equals (") | | strPassword.equals (")) / / determine whether the user name is equal to "" and the password is equal to "" tv.setText ("failed to register, please re-modify the information before registering") / / otherwise, the output of the execution result text box is "Registration failed, please re-modify the information before registering" else {tv.setText (strname+ "Registration success"); / / if the conditions are met, the output of the execution result text box is "Registration success" Intent intent=new Intent (MainActivity.this, success.class); intent.putExtra ("strname", strname) Intent.putExtra ("strPassword", strPassword); / / intent.putExtra ("strname", strname); intent.putExtra ("sex", str); intent.putExtra ("str1", str1); startActivity (intent);} above is all the content of the article "how to realize the registration page to jump to the login page". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.