Public class MainActivity extends the Activity {
Private Button Button;
@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
The button=(button) the findViewById (R.i d.m ainButton1);
Button. SetOnClickListener (new View. An OnClickListener () {
@ Override
Public void onClick (View v) {
//TODO Auto - generated method stub
//methods: USES his Intent to send data directly
/* Intent Intent=new Intent (MainActivity. This, MainActivity2. Class);
Intent. PutExtra (" name ", "Nicole");
Intent. PutExtra (" age ", 25).
Intent. PutExtra (" address ", "Shenzhen");
*/
//method 2, transmit data Bundle
Intent intent=new Intent();
Intent. SetClassName (" com. Mycompany. Myapp7 ", "com. Mycompany. Myapp7. MainActivity2");
Bundle Bundle=new Bundle ();
//bundle. PutString (" name ", "1");
Bundle. PutInt (" name ", 9);
Bundle. PutInt (" age ", 28).
Bundle. PutString (" address ", "China");
Intent. PutExtras (bundle);
StartActivity (intent);
}
});
}
}
CodePudding user response:
Elder brother ah, you help me write out at once