'SpannableStringBuilder - BOLD or NORMAL text formatting function
I know this is a simple question but your answer would mean a lot to me, so thank you in advance. What would a function look like that could click the formating button when the text is marked and the function performs bolding or returns the text as normal? Please help me.
formating.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Spannable spannableString = new SpannableStringBuilder(editText.getText());
spannableString.setSpan(new StyleSpan(Typeface.BOLD),
editText.getSelectionStart(),
editText.getSelectionEnd(),
0);
editText.setText(spannableString);
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
