I am trying to set BulletSpan in my Edit-text. So basically what i want to implement is, when i click on Button it should add bullet to the starting of that particular line and if i click again in that same line then it should automatically remove Bullet from that line. If i press enter then also automatically it should add new Bullet to that line. For the reference you can download this app from play store and check bullet span how exactly it works.
The problem i am facing right now is when i apply BulletSpan to any line it show's that line with Bullet but when i retrieve it after saving my file in SDcard i am getting 2 Bullets to particular string and also the format of string and bullet is not proper. For the reference please check below image.
My Code.
On Bullet Button click event i have following code.
startSelection = edtNoteDescription.getSelectionStart();
endSelection = edtNoteDescription.getSelectionEnd();
mSpannable = edtNoteDescription.getText();
mSpannable.setSpan(new BulletSpan(), 0, endSelection, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
for saving my file to SDcard i have used following code.
Spanned spannedText = edtNoteDescription.getText();
StringBuilder sbOutput = new StringBuilder();
AppHtml.withinHtml(sbOutput, spannedText);
Here AppHtml is a Html.java class which i have downloaded from internet.
And here is a final code that shows how i am retrieving a code
Spanned spanHTMLData = AppHtml.fromHtml(strGetData);
edtNoteDescription.setText(spanHTMLData);
0 comments:
Post a Comment