Created
June 27, 2016 02:40
-
-
Save yujuwon/41433dfa2e58c121fdc20c090908392f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Hashtag extends ClickableSpan { | |
| public interface ClickEventListener{ | |
| void onClickEvent(String data); | |
| } | |
| private ClickEventListener mClickEventListener = null; | |
| private Context context; | |
| private TextPaint textPaint; | |
| public Hashtag(Context ctx){ | |
| super(); | |
| context = ctx; | |
| } | |
| public void setOnClickEventListener(ClickEventListener listener){ | |
| mClickEventListener = listener; | |
| } | |
| @Override | |
| public void updateDrawState(TextPaint ds) { | |
| textPaint = ds; | |
| ds.setColor(ds.linkColor); | |
| ds.setARGB(255, 30, 144, 255); | |
| } | |
| @Override | |
| public void onClick(View widget) { | |
| TextView tv = (TextView) widget; | |
| Spanned s = (Spanned) tv.getText(); | |
| int start = s.getSpanStart(this); | |
| int end = s.getSpanEnd(this); | |
| String theWord = s.subSequence(start + 1, end).toString(); | |
| mClickEventListener.onClickEvent(theWord); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment