Android Question Problem serializing CSBuilder with PCSBuilderPlus class

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Using the PCSBuilderPlus class, as posted here:
https://www.b4x.com/android/forum/threads/save-load-text-formatted.92263/#post-583864

Nearly got this working but get this error when trying to retrieve the byte array with ToBytes (made Public):

java.lang.RuntimeException: Cannot serialize object: android.widget.EditText{4adef6f VFED..CL. ......ID 0,264-1056,1023 #b}

EditText is my SQL EditText. Error is resolved if I don't make the CSBuilder clickable, so if I don't do in my formatting Sub:

B4X:
cs.EnableClickEvents (edtSQL)

Any idea how to solve this?

RBS
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
a edittext cannot be serialized. Serialize edittext.text

So how should I write the class Sub then?
Currently it is:

B4X:
'EnableClickEvents (Label as android.widget.TextView)
'This method should be called when using a clickable span.
Public Sub EnableClickEvents(lbl As Label) As clsPCSBuilder
 cs.EnableClickEvents(lbl)
 data.Add(Array("EnableClickEvents",lbl))
 Return Me
End Sub

RBS
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
I did not check a code by eyes, but it looks workable.

Sub PrepareAndWriteStrings prepares "strings" and writes them to disk.
Of course, similar subroutine will not a part of real program. We need to write to disk once only.

Then Test activity reads previously prepared strings into memory and converts them to CSBuilder. To do this it uses a mapObjects, which is necessary to create in run-time.

I was not able to move restore part into class due to Clickable / EnableClickEvents.
Guess, the same problems like in your code. So I used a module.
 

Attachments

  • PCSBuilder.zip
    13.8 KB · Views: 242
Last edited:
Upvote 0
Top