Android Question Wrap text when copying and paste does not keep original text formating

hookshy

Well-Known Member
Licensed User
Longtime User
When I paste a text in an edit text, it is displayed well in the edittext that is set to multiline and wrap text.
Then I save this to mysql database, when I display the text again it does not wrap on the label because the text is treated like one row character set .

Where is the problem ? when storing the text into database or it is just the way it goes, the pasted text does not keep formating ?

My idea to fix this is:
- test in edit text_changed the new and old values , when diference between the length is greater than 1 then the text is pasted from another source
- then modify the text and insert a <cr> by measuring the text width or by fixed width

Thanks
 

hookshy

Well-Known Member
Licensed User
Longtime User
Have you checked to see what the saved data looks like in the database table itself?
HeidiSQL or MySQL Workbench will both show you exactly what's n the table.
Yes, my sql is showing a single line row
I have cecked how what'up is treating single line rows ....it actualy split the string to wrap to a label width
I guess I have to do it also when displaying in label in the feed, users usualy do paste things and does not care how the string is formated so ...


How do you test if the string is a single row ...serch for cr , contains(chr(unicode number))?
 
Last edited:
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Hmm that's a good question. I believe that carriage return and line feed (CR+LF) in
Linux is just \n, so that would be the same in Android too. I suppose that you could try looking for that during the copy and paste procedure.
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
I must create routine to insert Chr(10) every 30 caracters or the maximum char number that fit the label width
I am working on it ..:)
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
B4X:
                    Dim content As String
                    content="This is a single line text that will be splited to show up as multiline text ,the code suports some improvements but it works"
                    
                    
                    Dim str() As String
                    str=Regex.Split(" ",content)
                    For k=6 To str.Length-1 Step 6           
                        str(k)=str(k)&Chr(10)   
                    Next
                        
                    Dim sb As StringBuilder
                    sb.Initialize
                    For n=0 To str.Length-1
                        sb.Append(str(n)).Append(Chr(13))   
                    Next
                    Info.content=sb.ToString
 
Upvote 0
Top