2011-04-15 208 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