如何解决在AlertDialog中向消息添加超链接邮件
|| 我有一个“关于”菜单按钮,希望在我的邮件中添加一条“联系”消息。 我可以将带有超链接的邮件地址放入电话中的默认邮件应用程序吗? 谢谢。解决方法
您可以在“关于”对话框的“ 2”上的XML定义中使用“ 0”或在代码中使用“ 1”。我假设但尚未尝试过,如果文本的格式为“ 3”,它将打开电子邮件应用程序。它使用我尝试过的
http://
打开浏览器。
编辑:
对于可以将ѭ5分配给setView
的基本视图,您可以执行以下操作:
TextView emailLink = new TextView(myActivity.this);
emailLink.setAutoLinkMask(true);
emailLink.setText(\"mailto://<your email address>\");
AlertDialog aboutBox = new AlertDialog(myActivity.this);
aboutBox.setView(emailLink);
这是伪代码,可能需要根据您的情况进行修改。
编辑:
对于更复杂的视图,请尝试:
LinearLayout aboutLayout = new LinearLayout(myActivity.this);
aboutLayout.setOrientation(LinearLayout.VERTICAL);
TextView aboutText = new TextView(myActivity.this);
TextView emailLink = new TextView(myActivity.this);
emailLink.setAutoLinkMask(true);
emailLink.setText(\"mailto://<your email address>\");
// addView is best used with setting LayoutParams.
// eg addView(view,layoutParams). The following is for simplicity.
aboutLayout.addView(aboutText);
aboutLayout.addView(emailLink);
AlertDialog aboutBox = new AlertDialog(myActivity.this);
aboutBox.setView(aboutLayout);
更好的方法是用XML定义布局,然后手动对其进行充气,然后使用addView
将其添加到AlertDialog
中。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。