Android Jump Intent Simple Tutorial

Source: Internet
Author: User

How to jump:

1) Simple jump, without parameters:

private void Onclicklisener () {

TODO auto-generated Method Stub

Btn_login_register.setonclicklistener (New View.onclicklistener () {

@Override

public void OnClick (View v) {

TODO auto-generated Method Stub

// intention, intention , Parameters 1 : Indicates where the current is, parameter two : Jump to where

Intent intent=new Intent (mainactivity.this,register.class);

Start Intent

MainActivity.this.startActivity (Intent);

Close Current Activity

MainActivity.this.finish ();

}

});


1) with parameter jump



Btn_register_reg.setonclicklistener (New View.onclicklistener () {

@Override

public void OnClick (View v) {

TODO auto-generated Method Stub

Intent intent=new Intent (register.this,mainactivity.class);

String Username=et_register_username.gettext (). toString ();

String Password=et_register_password.gettext (). toString ();

int A=username.trim (). Length ();

int B=password.trim (). Length ();

if (a>0 && b>0) {

Intent.putextra ("username", username);

Intent.putextra ("password", password);

StartActivity (Intent);

Register.this.finish ();

}else{

Toast.maketext (Register.this, "Please enter the user name and the password greater than 8 less than 16 digits;", 2000);

SYSTEM.OUT.PRINTLN ("Error! ");

}

}

});



Receive parameters:

private void Intent () {

TODO auto-generated Method Stub

Intent intent=getintent ();

String Username=intent.getstringextra ("username");

String Password=intent.getstringextra ("password");

Et_login_user.settext (username);

Et_login_password.settext (password);

SYSTEM.OUT.PRINTLN (username);

SYSTEM.OUT.PRINTLN (password);

}





This article is from the "9151568" blog, please be sure to keep this source http://9161568.blog.51cto.com/9151568/1673552

Android Jump Intent Simple Tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.