Create an activity which comprises of
1) an edittext (Commonsware RichEditText)
2) a toolbar with the following buttons
Bold, Italic, underline, strikethrough, font, Center Align, Left Align, Right Align, Justified,...etc
4) A Save button
Usage:
User enters text and edits it by selecting text as a whole or parts. Effects are applied to selected text.When the user is finished editing the text into the editor, he clicks Save button. Everything is read from the RichEditText and sent to a database for later usage with the tags and formatting in html. I use the following code for saving and retriving.
Spanned s = Html.fromHtml("<i>Hi</i> There ! <b>how're you ?</b>");
et.setText(s);
//--save to string--
Editable e = et.getText();
String s2 = Html.toHtml(e);
//--restore from string--
Spanned s3 = Html.fromHtml(s2);
et.setText(s3);
src: Copy to clipboard using commonsware cwac-richedit library
The Problem:
I have to apply Bold, Italic, underline, strikethrough, font, Center Align, Left Align, Right Align, Justified,...etc to selected text onClick()
of a button in a tool bar different than an action bar button. Is there any way I can place the entire view shown in the actionbar when selection is made in a layout above the RichEditText? Say a Horizontal LinearLayout or some adaptive layouts?
It would be really helpfull if some one can tell he how to add any one effect to a selected text on click of a button. I saw the following method but not sure what is T value.
myRichEditText.applyEffect(effect, value);
Thanks.