2017-03-23 38 views

回答

0
   // Create a new Intent object as container for the result 
       final Intent data = new Intent(); 

       // Add the required data to be returned to the MainActivity 
       data.putExtra(EXTRA_DATA, "Some interesting data!"); 

       // Set the resultCode as Activity.RESULT_OK to 
       // indicate a success and attach the Intent 
       // which contains our result data 
       setResult(Activity.RESULT_OK, data); 

       // With finish() we close the DetailActivity to 
       // return back to MainActivity 
       finish(); 
0

您可以通過綁定轉移您的數據:

從下面的代碼的活動中使用,以捆綁ADDD數據:

Bundle bundle = new Bundle(); 
bundle.putString("key", "your string"); 
// set Fragmentclass data as fragment arguments 
YourFragment fobj = new YourFragment(); 
fobj.setArguments(bundle); 

和片段,你可以得到你的數據:

String strtext = getArguments().getString("key");