Created
September 4, 2015 09:12
-
-
Save Sebring/b86c00b4a0a09abbc14c to your computer and use it in GitHub Desktop.
HtmlTextView - Android TextView to in databinding where content is HTML
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
import android.content.Context; | |
import android.text.Html; | |
import android.text.method.LinkMovementMethod; | |
import android.util.AttributeSet; | |
import android.widget.TextView; | |
public class HtmlTextView extends TextView { | |
public HtmlTextView(Context context) { | |
super(context); | |
} | |
public HtmlTextView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
public HtmlTextView(Context context, AttributeSet attrs, int defStyleAttr) { | |
super(context, attrs, defStyleAttr); | |
} | |
@Override | |
public void setText(CharSequence text, BufferType type) { | |
super.setText(Html.fromHtml(text.toString()), type); | |
this.setMovementMethod(LinkMovementMethod.getInstance()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This enhanced TextView is handy when using databinding and content is HTML.
entity:
view: