你好,我現在用的是下面的代碼linkify電子郵件地址和URL,並且正在就如同我需要它但是如果你點擊任何地方除了網址和電子郵件的白色文字是斷開鏈接變得黑色並且不可讀。不是一個大問題,但只是一些很煩人的格式化鏈接文字的顏色的onclick將不勝感激任何幫助。警告對話框Linkify但保留文白
final SpannableString s = new SpannableString("Some text here before link http://www.google.com some more text then email [email protected]");
Linkify.addLinks(s, Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES);
final AlertDialog d = new AlertDialog.Builder(MainMethod.this)
.setPositiveButton(android.R.string.ok, null)
.setIcon(R.drawable.about)
.setTitle(R.string.about_title)
.setMessage(s)
.create();
d.show();
((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
所以現在下面的文字「這裏的一些文字鏈接之前一些文本,然後通過電子郵件發送」顯示在對話框中白色的,但按下時變爲黑色
編輯:
的Java
LayoutInflater li = LayoutInflater.from(this);
View view = li.inflate(R.layout.link, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Insert Title Here");
builder.setView(view).create().show();
TextView text=(TextView) findViewById(R.id.link1);
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/link1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Body text with email [email protected] and a website http://google.com"
android:autoLink="web|email"
android:textColorLink="#0000ff"
android:textColor="#ffffff"
/>
</LinearLayout>