tags:

views:

149

answers:

2

I have an EditText where users can set text to bold, italic, etc but I can't figure out how to save that text with styles as .txt file/any otherway to save it.If we save as html page we can't edit the webview. I use getText but that only returns text and no style info.

Any help is appreciated.

Regards

vani

A: 

I think the best way would be, if you build an own class, which handles the styles. I think, if its a EditText and you can say, part of the text should be bold, so you save something like "10.20.b|" into a temporary var. Later you can handle your styles, parsing the styles-var, split it by "|" and analyze the "10.20.b" which would mean something like "position 10 to position 10+20 is bold". To save it, use XML for example, like:

<?xml version="1.0" encoding="utf-8"?>
<styles>0.4.b|6.2.i|</styles>
<text>This is a wonderful text! OH MY GOD!!!</text>

This would produce:

This is a wonderful text! OH MY GOD!!!

Keenora Fluffball
A: 

This is nice but user has to select the typed text..so we can't give the position of the text to be bold(or some style) statically..So presently I am able get all the styles for my text as user selects of edit text.Problem is how to save it.If we save it as .txt we lost our styles..only plain text would be saved as .txt file.

Regards,

vani

vani