2011-03-29 2 views
2

안녕하세요. 이메일 주소와 URL을 연결하는 데 다음 코드를 사용하고 있습니다. 링크가없는 흰색 텍스트를 URL과 이메일 옆의 아무 곳이나 클릭하면 작동합니다. 검게되고 읽을 수 없게된다. 거대한 거래는 아니지만 링크 된 텍스트 onclick의 색상을 포맷하는 데 도움이되는 내용은 크게 감사 할 것입니다.경고 대화 상자 링크가 있지만 텍스트는 흰색으로 유지합니다.

  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()); 

는 이제 다음과 같은 텍스트가 "좀 더 텍스트가 다음 이메일로 링크하기 전에 여기에 일부 텍스트는"대화 상자에서 흰색 표시되지만 누르면 검게

편집 :

자바

 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 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> 

답변

2

아마도 이것은 올바른 방법이 아니지만 명시 적으로 textColor 특성을 설정하면이 문제를 해결할 수 있습니다.

<TextView android:id="@+id/text1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:autoLink="all" 
    android:textColor="#ffffff"/> 

나는 당신의 텍스트 색상을 설정할 때 styles을 사용할 생각 나게하지 않은 경우 내가 놓칠 것,하지만 거기입니다. XML에 텍스트 뷰에

0

설정이

android:textColor="@android:color/secondary_text_dark_nodisable" 

this answer 참조하십시오.

관련 문제