Android Bundle class

Source: Internet
Author: User

Bundle Class: Vertical screen of activity to the activity of the horizontal screen, will be the activity of vertical screen to kill the activity of the horizontal screen to create, vertical screen activity will have some calculation results, can be stored with data, stored in memory, Then there is the activity of the horizontal screen. Intent class Putextra (private  Bundle Mextras; Bundle is a map,

First activity:

 Packagecom.sxt.day04_01;Importcom.sxt.day04_01.entity. User;Importandroid.app.Activity;Importandroid.content.Intent;ImportAndroid.os.Bundle;Importandroid.text.TextUtils;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;ImportAndroid.widget.EditText; Public classLoginactivityextendsActivity {EditText metid,metpwd; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_login);        Initview ();    Setlistener (); }    Private voidSetlistener () {Setexitclicklistener ();//set the listener for the exit buttonSetloginclicklistener ();//Set the login button listener    }    //Set the login button listener    Private voidSetloginclicklistener () {Findviewbyid (r.id.btnlogin). Setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {String ID=Metid.gettext (). toString (); if(Textutils.isempty (id)) {metid.seterror ("Number cannot be empty"); return ; } String pwd=Metpwd.gettext (). toString (); if(Textutils.isempty (pwd)) {Metpwd.seterror ("Password cannot be empty"); return ; } Intent Intent=NewIntent (loginactivity. This, Mainactivity.class); Bundle Data=NewBundle (); Data.putstring ("id", id); Data.putstring ("Password", PWD);                Intent.putextras (data);            StartActivity (Intent);    }        }); }    //set the listener for the exit button    Private voidSetexitclicklistener () {Findviewbyid (r.id.btnexit). Setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {finish ();    }        }); }    Private voidInitview () {Metid=(EditText) Findviewbyid (R.id.etid); Metpwd=(EditText) Findviewbyid (R.ID.ETPWD); }}



A second activity:

Package com.sxt.day04_01;

Import android.app.Activity;
Import android.content.Intent;
Import Android.os.Bundle;
Import Android.util.Log;

public class Mainactivity extends Activity {

@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Intent intent=getintent ();
String Id=intent.getstringextra ("id");
String Pwd=intent.getstringextra ("password");
Bundle data = Intent.getextras ();
String id=data.getstring ("id");
String pwd=data.getstring ("password");
LOG.I ("main", "id=" +id+ ", Password:" +pwd);
}

}

Android Bundle class

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.