Linkify the text if text from string array

Put your problem here if it does not fit any of the other categories.

Linkify the text if text from string array

Postby sarahjosh » Sun Sep 11, 2011 10:52 am

<string-array name="word">


<string-array name="desc">
<item>This is a <u>unique</u> ...</item>
<item>Its<u>parent</u> user</item>
<item>This memory space used.... </item>
In an activity I have 2 textviews.One for displaying word and second one for description. In the desc textview, how can it linkify the term same as word(for example "unique" in first definition) and onclick of that it should show a page with word "unique" and corresponding description. Can anybody please help how to do this? Thank you..

final Context context = this.getApplicationContext();
CharSequence sequence = Html.fromHtml(context.getString(R.array.word));
SpannableStringBuilder strBuilder = new SpannableStringBuilder(sequence);
UnderlineSpan[] underlines = strBuilder.getSpans(0,strBuilder.length(),UnderlineSpan.class);
for(UnderlineSpan span : underlines) {
int start = strBuilder.getSpanStart(span);
int end = strBuilder.getSpanEnd(span);
int flags = strBuilder.getSpanFlags(span);
ClickableSpan myActivityLauncher = new ClickableSpan() {
public void onClick(View view) {
if(view == wordTextview){


strBuilder.setSpan(myActivityLauncher, start, end, flags);
}catch(Exception e){


Once Poster
Once Poster
Posts: 1
Joined: Sun Sep 11, 2011 10:46 am


Return to Other Coding-Problems

Who is online

Users browsing this forum: MSNbot Media and 29 guests