-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathClickSpan.java
33 lines (28 loc) · 891 Bytes
/
ClickSpan.java
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
import android.content.Context;
import android.graphics.Typeface;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.View;
// A helper class for ClickableSpans
public class ClickSpan extends ClickableSpan {
private final OnClickListener mListener;
private final Context mContext;
public ClickSpan(final Context context, final OnClickListener listener) {
this.mContext = context;
this.mListener = listener;
}
@Override
public void onClick(final View widget) {
if (this.mListener != null) {
this.mListener.onClick();
}
}
@Override
public void updateDrawState(final TextPaint ds) {
ds.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
ds.setUnderlineText(true);
}
public interface OnClickListener {
void onClick();
}
}