Define a custom TextView that displays HTML

This commit is contained in:
veyndan 2017-04-14 13:49:18 +01:00
parent 0fbd3a9cf6
commit ce1e293d87
3 changed files with 25 additions and 29 deletions

View file

@ -0,0 +1,21 @@
package fr.free.nrw.commons.ui.widget;
import android.content.Context;
import android.support.v7.widget.AppCompatTextView;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
/**
* An {@link AppCompatTextView} which formats the text to HTML displayable text and makes any
* links clickable.
*/
public class HtmlTextView extends AppCompatTextView {
public HtmlTextView(Context context, AttributeSet attrs) {
super(context, attrs);
setMovementMethod(LinkMovementMethod.getInstance());
setText(Html.fromHtml(getText().toString()));
}
}