Android Question Problem serializing CSBuilder with PCSBuilderPlus class

Discussion in 'Android Questions' started by RB Smissaert, Oct 17, 2018.

  1. RB Smissaert

    RB Smissaert Well-Known Member Licensed 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:

    Code:
    cs.EnableClickEvents (edtSQL)
    Any idea how to solve this?

    RBS
     
  2. Semen Matusovskiy

    Semen Matusovskiy Well-Known Member Licensed User

    By design PCSBuilderPlus is able to reproduce absolutelly everything. Post your test as zip.
     
  3. DonManfred

    DonManfred Expert Licensed User

    a edittext cannot be serialized. Serialize edittext.text
     
    Peter Simpson likes this.
  4. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

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

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

    Erel Administrator Staff Member Licensed User

    This code cannot work. You should remove the data.add line and manually call EnableClickEvents after you load the builder.
     
  6. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    Yes, thanks, just had come to the same conclusion.

    RBS
     
  7. Semen Matusovskiy

    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.
     

    Attached Files:

    Last edited: Oct 18, 2018
    Mahares likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice