1, the first step to make two Activity with button and input box 2, the second step in the MainActivity declared in two class, and register them 3, the third step in MainAvtivity initialize button, input box 4, step 4. Click on the button design events button setOnClickListener (this); 5, step 5 in the jump button click event interface, and to send data over the past Intent Intent=new Intent (); Intent. PutExtra (key, "content");//set the request code for 1 startactivityforresult (intent, 1); Step 6, 6 jump interface initialization after jump interface button and input box 7, step 7 to get their data receiving MainActivity Bundle Bundle=getIntent (). GetExtras (); String cc=bundle. Get String (key); The editText. SetText (" hello "+ cc); Step 8, 8 design button click event, and to send data over Intent Intent=new Intent (); Intent. PutExtra (key, "content");//receives the request, return code for 1 setresult (1, intent); Finish (); Step 9, 9 back to MainActivity to receive the data returned protected void onActivityResult (int requestCode, int the resultCode, @ Nullable Intent data) {if (data=https://bbs.csdn.net/topics/=null) return; Bundle Bundle=data. GetExtras (); String cc=bundle. Get String (key); The editText. SetText (" hello "+ cc); }
CodePudding user response:
Suggestions according to the format to write code
CodePudding user response:
Can layout look better, had better put the code in figure, don't worry, we can't understand and just can't understand what you want to ask questions