This article describes the method of using Intent to implement page jump and parameter passing in Android Activity. Share it for your reference, as follows:
Create a new one
package ; import ; import ; import ; import ; import ; import ; public class FirstActivity extends Activity { private Button myButton; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { (savedInstanceState); setContentView(); myButton = (Button) findViewById(); (new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(); //Intent pass parameters ("testIntent", "123"); (, ); (intent); } }); } }
Create a second new
package ; import ; import ; import ; import ; public class SecondActivity extends Activity{ private TextView myTextView; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub (savedInstanceState); setContentView(); //Use the Intent object to get the parameters passed by FirstActivity Intent intent = getIntent(); String value = ("testIntent"); myTextView = (TextView) findViewById(); (value); } }
Both activities must be registered in
For more information about Android related content, please check out the topic of this site:Android programming activity operation skills summary》、《Android View View Tips Summary》、《Summary of Android's SQLite database skills》、《Summary of Android operating json format data skills》、《Android database operation skills summary》、《Android file operation skills summary》、《A summary of SD card operation methods for Android programming and development》、《Android development introduction and advanced tutorial》、《Android resource operation skills summary"and"Android control usage summary》
I hope this article will be helpful to everyone's Android programming design.