rameshvoltella / Hash-Tags-Android

This is a sample of handling hashtags (#) that contain in a text,the tags are clickable and user can do specifc actions for the corresponding hash tags.
MIT License
51 stars 11 forks source link

Enhance to support html tags #2

Closed Ahmad19860 closed 9 years ago

Ahmad19860 commented 9 years ago

Hi, Thanks for creating a useful library. I was looking for hashtag feature and this library is doing the same.

I need to support the HTML tags along with hashtag. I mean if there a string having some HTML tags, it should show that as well. As of now this is not recognizing the HTML tags.

Please suggest a solution to support the HTML tags. I tried with Html.fromHtml(); but not worked.

rameshvoltella commented 9 years ago

let me check that soon

Ahmad19860 commented 9 years ago

thanks to comment, meanwhile give me an idea if you have to continue with...

rameshvoltella commented 9 years ago

what html tag you need to reconize ? u mean a hyper link?

Ahmad19860 commented 9 years ago

Actually I am showing data in listview having article title and its description. The description may be input by user or copied from other sources (may be from article on web or blog).

Earlier i was showing the description converting it to spanned text. Now I need to implement the hashtag searching on description. So I use your code. But it is not working with html string.

Example String may be in this format - "

<font face=\"Arial, Verdana\"><span style=\"font-size: 13.3333330154419px;\">What Is #Agile?
<font face=\"Arial, Verdana\"><span style=\"font-size: 13.3333330154419px;\">
<font face=\"Arial, Verdana\"><span style=\"font-size: 13.3333330154419px;\">The Agile movement proposes alternatives to traditional project management. #Agile approaches are typically used in software development to help businesses respond to unpredictability."

rameshvoltella commented 9 years ago

try to set like this mHashTagTextView.setText(mTagSelectingTextview.addClickablePart( Html.fromHtml(testText).toString(), this, mhyperlickStatus, hashtagColor), BufferType.SPANNABLE);

Ahmad19860 commented 9 years ago

Yes I tried this but not worked.

Finally it worked after few modification.

  1. I changed the String parameter to CharSequence in method addClickablePart() of TagSelectingTextview.
  2. I copied the string from string.xml and initialize it in .java file.

    After these changes all tags are recognized along with hashtag and its click event. Important change is, initializing string in .java file instead of string.xml. I don't know why it not worked if string is initialized from string.xml. I will analyze it later.

BTW, Thanks for your valuable time and comments.

rameshvoltella commented 9 years ago

okey am checking will update code soon

rameshvoltella commented 9 years ago

updated the code please check