1

我得到了以下用于从用户创建电子邮件表单。该应用程序收集了 3 个字符串,但我不知道如何将提交按钮与此电子邮件代码合并。

    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("message/rfc822");
    i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"recipient@example.com"});
    i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
    i.putExtra(Intent.EXTRA_TEXT   , "body of email");
    try {
        startActivity(Intent.createChooser(i, "Send mail..."));
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
4

1 回答 1

2

Button您在布局中创建一个:

<ParentLayout [...]>

   <Button [....] android:id="@+id/myButton"/>

</ParentLayour />

创建您的对象Button

Button btn = (Button) findViewById(R.id.myButton);

设置一个OnClickListner

btn.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 // Do the email stuff in here.
             }
         });)
于 2013-05-27T01:06:35.690 回答