0
我有一個「關於」菜單按鈕,並希望爲我的郵件添加「聯繫人」消息。 我可以把超鏈接的郵件地址放在手機中默認的郵件應用程序中嗎? 謝謝。在AlertDialog中添加超鏈接(郵件)
我有一個「關於」菜單按鈕,並希望爲我的郵件添加「聯繫人」消息。 我可以把超鏈接的郵件地址放在手機中默認的郵件應用程序中嗎? 謝謝。在AlertDialog中添加超鏈接(郵件)
您可以在XML定義中使用android:autoLink
或在About對話框中使用TextView
代碼中的setAutoLinkMask
。我會假設,但還沒有嘗試過,如果文本的形式是mailto://
它會打開電子郵件應用程序。它使用我試過的http://
打開瀏覽器。
編輯:
對於您可以分配的AlertDialog
與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
的更好的方法。
@techiServices:但我只是想超鏈接「聯繫」的消息,不是所有的「關於」AlertDialog。就像所有關於AlertDialog的超鏈接?不是? – androniennn 2011-04-15 23:19:26
不知道爲什麼您要爲「關於屏幕」使用AlertDialog,但您需要做的是以代碼或XML創建一個包含「關於屏幕」位的佈局。如果您使用的是XML或'setAutoLinkMask',如果您使用的是代碼,則在此佈局中添加一個「TextView」並分配'android:autoLink'。 – techiServices 2011-04-15 23:28:00
@techiServices:所以我不必使用菜單和「關於」選項來顯示「關於」AlertDialog?!我很困惑!請你能通過我的鏈接瞭解你想說的話嗎? – androniennn 2011-04-15 23:34:04