The Obj_library has not the As method, Obj_library and Obj_library_g are defferent classes.
if you want to change libraries dynamically, you can do that with object reference like this
B4X:
public obj as Object
Public Obj_library As library01
Public Obj_library_g As library01g
Public Obj_library_t As library01t
condition 1
obj=Obj_library
condition 2
obj=library01g
condition 3
obj=library03g
public obj as Object
Public Obj_library As library01
Public Obj_library_g As library01g
Public Obj_library_t As library01t
condition 1
obj=Obj_library
condition 2
obj=library01g
condition 3
obj=library03g
It seems like polymorphism and inheritance. During runtime you have to make sure that all libraries should have and share common behaviors.
If the methods are identical and you're certain about the object's type at runtime, you can use a method to re-assign the library.
B4X:
Sub SwitchLibrary(newLibrary As Object)
Obj_library = newLibrary
End Sub
'Call it like this:
SwitchLibrary(Obj_library_g)
This defeats the purpose - by the time I get to the collection_serializer the library being serialized should be set to either library01g or library01t.
I have come to the conclusion that what I want to do this way is not possible - so I have come up with a small sub that just does one library or the other based on a pointer.