Activity
1. Role
Control container
2. Create an activity
2.1 inherit the activity class
2.2 rewrite the oncreate method (the first operation will be called in the window)
2.3 Register in mainifest. xml
2.4 Add controls
Protected void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
Setcontentview (R. layout. activity_main );
Textview TV1 = (textview) findviewbyid (R. Id. textview1 );
Tv1.settext ("Hello kllmctrrl hello! ");
}
3. Activity and intent
3.1 page Jump
Activity01.startactivity (intent) Method
3.2 intent object
Component name --> activity/service...
Action --> fun
Data --> data
Extras -->
...
// Main
Button btn1 = (button) findviewbyid (R. Id. button1 );
Btn1.settext ("Press ");
Btn1.setonclicklistener (New buttonlistener ());
// Listener
Class buttonlistener implements onclicklistener {
@ Override
Public void onclick (view v ){
// Todo auto-generated method stub
Intent intent = new intent ();
Intent. setclass (mainactivity. This, otheractivity. Class );
Intent. putextra ("tag", "123 ");
Mainactivity. This. startactivity (intent );
}
}
// Other
Textview TV1 = (textview) findviewbyid (R. Id. textview2 );
Intent intent = getintent ();
Tv1.settext (intent. getstringextra ("tag "));
// OthersProgramActivity
Uri uri = URI. parse ("smsto: // 020 ");
Intent intent = new intent (intent. action_sendto, Uri );
Intent. putextra ("sms_body", "SMS text ");
Startactivity (intent );
------------------------------------------------------