我想将“结果”数据从我的第一个(主要)活动转移到
我的Custaddress活动,其中包含有关客户详细信息的编辑文本,然后将其发送到电子邮件中。电子邮件/编辑文本效果很好-但我想
在电子邮件正文字符串中添加“ result.toString”。如何将“结果”转移到第二项活动?我相信这与arg有关吗?
这是我第一次活动的代码。

DecimalFormat decimalFormat = new DecimalFormat(COMMA_SEPERATED);
          result.append("\nTotal: £"+decimalFormat.format(totalamount));
     AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this);
      alertDialogBuilder.setMessage(result.toString());
      alertDialogBuilder.setTitle("YOUR ORDER");
      alertDialogBuilder.setPositiveButton("Accept",
      new DialogInterface.OnClickListener() {

         @Override
         public void onClick(DialogInterface arg0, int arg1) {
            //do what you want to do if user clicks ok
             //Intent intent = new Intent(context, Custaddress.class);
            // startActivity(intent);
             Intent custaddress = new Intent(getApplicationContext(),com.example.frytest.Custaddress.class);
             startActivity(custaddress);
         }
      });
      alertDialogBuilder.setNegativeButton("Decline",
      new DialogInterface.OnClickListener() {

         @Override
         public void onClick(DialogInterface dialog, int which) {
            //do what you want to do if user clicks cancel.
         }
      });

      AlertDialog alertDialog = alertDialogBuilder.create();
      alertDialog.show();

最佳答案

写在活动中传递数据

Intent custaddress = new Intent(getApplicationContext(),com.example.frytest.Custaddress.class);
custaddress.putExtra("key",value);
startActivity(custaddress);


在捕获数据的活动中编写以下代码

Intent intent=getIntent();
String mString=intent.getStringExtra("key");


希望这能够帮到你

09-04 15:07
查看更多