2013-07-17 3 views
1

간단한 브로셔 응용 프로그램을 쓰고 있습니다. 나는 textview에 이메일 주소가있는 텍스트를 가지고있다.이메일 주소에 대한 TextView 구문 분석

<string name="wbl_contacts"> 
<p><strong>CONTACT</strong></p> 
<p> 
    <strong>Where you can find us</strong> 
    1525 Newton St NW 
    Washington D.C., DC 20010 
202.667.1192 
    For current listing of class schedule at each of our sites, e-mail <a href="mailto:[email protected]">[email protected]</a> 
    To learn about volunteer opportunities e-mail <a href="mailto:[email protected]">[email protected]</a> 
    To submit your resume for internship consideration e-mail <a href="mailto:[email protected]">[email protected]</a> 
    To submit work for consideration for publication in the WBL journal email <a href="mailto:[email protected]">[email protected]</a> 
    All other questions can be directed to <a href="mailto:[email protected]">[email protected]</a> 
or call us at 202-667-1192 </p> 
    </string> 

나는 메일 응용 프로그램과 같이 추가로 텐트 클래스를 사용하려고 시도하고는 : 전체 텍스트 뷰가 클릭 할 것처럼

//setting textviews 
     tv1 = (TextView)findViewById(R.id.tv1); 
     tv1.setMovementMethod(LinkMovementMethod.getInstance()); 
     //tv1.setText(Html.fromHtml(getString(R.string.wbl_contacts))); 

     tv1.setOnClickListener(new OnClickListener() { 
      public void onClick(View v) { 
       //This will open an email client. Find a way to use this code 
       //to open all email address on any android app page 
       Intent emailintent = new Intent(android.content.Intent.ACTION_SEND); 
       emailintent.setType("text/html"); 
       emailintent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] {tv1.getText().toString()}); 
       emailintent.putExtra(android.content.Intent.EXTRA_SUBJECT, ""); 
       emailintent.putExtra(android.content.Intent.EXTRA_TEXT,""); 
       startActivity(Intent.createChooser(emailintent, "Send mail...")); 
      } 
      }); 

내 응용 프로그램을 실행, 그것은 보인다 심지어 이메일 링크는하지만 모두가 마치 연결될 수있는 것처럼 강조됩니다 .... 조금 잃었습니다.

모든 제안이나 도움을 주시면 대단히 감사하겠습니다.

답변

0

예 이러한 종류의 동작에는 인 텐트를 사용하면 안됩니다. 대신 TextView를 연결해야합니다. linkify에 대한 자세한 내용은 here을 참조하십시오.

당신은 다음과 같은 일을 할 것입니다 :

Linkify.addLinks(tv1 , Linkify.EMAIL_ADDRESSES); 

편집 추가 답변 :

Linkify.addLinks(tv1 , Linkify.ALL); 

을 또는 당신은뿐만 아니라 HREF 이메일 주소와이 있다면

귀하의 사용 HTML 이메일에 일반 텍스트 대신 구문을 사용하므로 다음을 사용해야합니다.

tv1.setText(Html.fromHtml("your string"); 

모든 HTML 태그가 Android에서 지원되는 것은 아니지만 지원되는 HTML 태그 목록은 here입니다.

+0

감사합니다. –

+0

@that_developer가 작동합니까? 그럼 제발 +1 – Warpzit

+0

나를 위해 더 이상 작동하지 ... 이메일 주소 중 하나를 클릭하면 그것의 역할을 전체 텍스트 및 아니 이메일 애플 리케이션을 팝업 것처럼 ... –

관련 문제