Use Intent in Activity to implement page Jump and parameter transfer (conversion), activityintent
Create a firstavti.pdf. java
Package com. zhuguangwei; import android. app. activity; import android. content. intent; import android. OS. bundle; import android. view. view; import android. view. view. onClickListener; import android. widget. button; public class FirstActivity extends Activity {private Button myButton;/** Called when the activity is first created. * // @ Overridepublic void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. main); myButton = (Button) findViewById (R. id. myButton); myButton. setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {// TODO Auto-generated method stubIntent intent = new Intent (); // Intent transmits the intent parameter. putExtra ("testIntent", "123"); intent. setClass (FirstActivity. this, SecondActivity. class); FirstActivity. this. startActivity (intent );}});}}
Create the second SecondActivity. java
Package com. zhuguangwei; import android. app. activity; import android. content. intent; import android. OS. bundle; import android. widget. textView; public class SecondActivity extends Activity {private TextView myTextView; @ Overrideprotected void onCreate (Bundle savedInstanceState) {// TODO Auto-generated method stubsuper. onCreate (savedInstanceState); setContentView (R. layout. other); // use the Intent object to get the Intent intent parameter passed by FirstActivity = getIntent (); String value = intent. getStringExtra ("testIntent"); myTextView = (TextView) findViewById (R. id. myTextView); myTextView. setText (value );}}
Both activities must be registered in AndroidMenifest. xml.
(