正在加载图片...
Passing Data between Activities Intent Activity 1 Activity 2 /Create an activity using the constructor Intent intent new Intent(Activityl.this,Activity2.class //Create a bundle Bundle bundleData new Bundle(); /Create put string data in the bundle (key-value-pair) bundleData.putstring("key_name","name") bundleData.putstring("key_age","age"); /Create put the bundle data in the Extra of Intent intent.putExtras(bundleData); /Instead of using bundle,we can also put data,e.g., strings,directly in the Extra of Intent intent.putExtra("key_id","id"); intent.putExtra("key_address","address"); /Invoke the activity using the created intent startActivity(intent); Ex七才八 13Passing Data between Activities 13 Activity 1 Activity 2 Intent // Create an activity using the constructor Intent intent = new Intent(Activity1.this, Activity2.class); // Create a bundle Bundle bundleData = new Bundle(); // Create put string data in the bundle (key-value pair) bundleData.putString("key_name", "name"); bundleData.putString("key_age", "age"); // Create put the bundle data in the Extra of Intent intent.putExtras(bundleData); // Instead of using bundle, we can also put data, e.g., strings, directly in the Extra of Intent intent.putExtra("key_id", "id"); intent.putExtra("key_address", "address"); // Invoke the activity using the created intent startActivity(intent);
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有