blob: 1d5ee0e718760af24a325c48db6b12cf5378cbc7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package moe.yuuta.workmode.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.AttributeSet;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;
import moe.yuuta.workmode.R;
public class HtmlTextView extends AppCompatTextView {
public HtmlTextView(Context context) {
this(context, null);
}
public HtmlTextView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, android.R.attr.textViewStyle);
}
public HtmlTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray a = context.getTheme().obtainStyledAttributes(
attrs, R.styleable.HtmlTextView, defStyleAttr, 0);
setText(Html.fromHtml(a.getString(R.styleable.HtmlTextView_html)));
if (a.getBoolean(R.styleable.HtmlTextView_enableLinks, false)) setMovementMethod(new LinkMovementMethod());
}
}
|