2014-04-28 2 views
0

나는 단어에 대한 하이퍼 링크를주는 법을 알고 있지만 문단 내의 단어에 하이퍼 링크를 줄 필요가 있습니까?android에서 단락 내의 단어에 하이퍼 링크를 붙이는 방법

예를 들어 내 단락 :

여기에 내가이 단어 에 "조판 업계"하이퍼 링크를 추가 할
Lorem Ipsum is simply dummy text of the printing and "typesetting industry". Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. 

것을 가능? 그렇다면 해결책을 얻도록 도와주세요. 이 코드 아래 사용을 할 수

답변

2

,

TextView textView = (TextView)findViewById(R.id.text); 
     textView.setText("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."); 

     MatchFilter mMatchFilter = new MatchFilter() { 
      public final boolean acceptMatch(CharSequence s, int start, int end) { 
       return true; 
      } 
     }; 
     TransformFilter mTransformFilter = new TransformFilter() { 
      public final String transformUrl(final Matcher match, String url) { 
       return "www.google.com"; 
      } 
     }; 

     Pattern mPattern = Pattern.compile("typesetting industry"); 
     String scheme = "http://"; 
     Linkify.addLinks(textView, mPattern, scheme, mMatchFilter, mTransformFilter); 
+0

www.google.com을 반환하는 이유는 무엇입니까? – Madhu

+0

고마워요. – Madhu

+0

나는 그것이 당신을 위해 일하기 때문에 기쁘다. –

0

친애하는 Brindha 특정 텍스트에 대해이 작업을 사용, 당신은 당신의 요구 사항에 따라 웹 또는 이메일이나 전화 또는지도 또는 전부를 설정할 수 있습니다.

android : autoLink = "웹 | 이메일 | 전화 |지도 | 전체"

+0

답장을 보내 주셔서 감사합니다. 첫 번째 답변이 도움이되는 문단에서 diff 단어에 대한 별도의 링크를 제공해야합니다. – Madhu