Android:使用onclicklistener启动电子邮件意图
我可以使用以下内容从用户创建电子邮件表单。该应用程序收集了3个字符串,但我不知道如何将提交按钮与此电子邮件代码合并Android:使用onclicklistener启动电子邮件意图,android,Android,我可以使用以下内容从用户创建电子邮件表单。该应用程序收集了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
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();
}
在布局中创建一个
按钮
:
<ParentLayout [...]>
<Button [....] android:id="@+id/myButton"/>
</ParentLayour />
在ClickListner上设置
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Do the email stuff in here.
}
});)
创建对象线到哪里去了?(相对于活动)在onCreate()
方法中。您愿意让我通过电子邮件将活动文件发送给您,以便您可以查看它吗?
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Do the email stuff in here.
}
});)