mSpannableString = new SpannableString("12:00PM");
mSpannableString.setSpan(clickableSpan, 0, 7, 0);
mSpannableString.setSpan(new StyleSpan(Typeface.BOLD), 0, 7, 0);
TextView textView = new TextView(getContext());
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setText(mSpannableString);
mCancelFrom.setText(getString(R.string.cancel_from_text) + " " + mSpannableString);
i need to set the text to bold and make it clickable. the above code i have written in a dialog. the string "12:00PM" is getting displayed. but there is not bold effect on it and it is not clickable. can you hel me with this?
Try This ,it may be help to you
SpannableString ss = new SpannableString("12:00PM");
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View textView) {
startActivity(new Intent(SendSMS.this, SendSMS.class));
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
};
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(clickableSpan, 0, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
mCancelFrom.setText(getString(R.string.cancel_from_text) + " " + ss);