2011-04-15 206 views

回答

1

您可以在XML定义中使用android:autoLink或在About对话框中使用TextView代码中的setAutoLinkMask。我会假设,但还没有尝试过,如果文本的形式是mailto://它会打开电子邮件应用程序。它使用我试过的http://打开浏览器。

编辑:

对于您可以分配的AlertDialogsetView你可以做一个基本观点:

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的更好的方法。

+0

@techiServices:但我只是想超链接“联系”的消息,不是所有的“关于”AlertDialog。就像所有关于AlertDialog的超链接?不是? – androniennn 2011-04-15 23:19:26

+0

不知道为什么您要为“关于屏幕”使用AlertDialog,但您需要做的是以代码或XML创建一个包含“关于屏幕”位的布局。如果您使用的是XML或'setAutoLinkMask',如果您使用的是代码,则在此布局中添加一个“TextView”并分配'android:autoLink'。 – techiServices 2011-04-15 23:28:00

+0

@techiServices:所以我不必使用菜单和“关于”选项来显示“关于”AlertDialog?!我很困惑!请你能通过我的链接了解你想说的话吗? – androniennn 2011-04-15 23:34:04