Android Question [RESOLVED] strange issue accessing objects in a class library

giggetto71

Active Member
Licensed User
Longtime User
HI I am using the xChart custom library, for some reasons I need to access the points Element data,


1675150139301.png

so I created a tyep in my code
B4X:
Type GraphData (BarType As String, ShowTick As Boolean, X As String, YArray() As Double)

and what I do to get the single ElementData from the class is:

B4X:
GDataElem As GraphData
PointsNum = ADashxChart.Points.Size
For kk = 0 To PointsNum-1
   GDataElem = ADashxChart.Points.Get(kk)
   .......

now, the weird thing is that this code works in debug mode on the emulator but only in step mode...(!!??) If I remove the breakpoints, moving the elementData object into my object, fails and I get:

(ClassCastException) java.lang.ClassCastException: gigiosoft.MQTTAlert.xchart$_pointdata cannot be cast to gigiosoft.MQTTAlert.main$_graphdata

in release mode is always shows the exception.

I am sure there is another way to accessdata inside library classes but I don't know how..any idea?
thank you very much!
 

klaus

Expert
Licensed User
Longtime User
Your Type declaration is wrong.
The Type must be PointData.
Which is an internal type of xChart : Type PointData (X As String, YArray() As Double, ShowTick As Boolean, BarType As String)
The code below works:

B4X:
    Private n, i As Int
    For n = 0 To xChart1.Points.Size - 1
        Private pts As PointData
        pts = xChart1.Points.Get(n)
        Log(pts.X)
        For i = 0 To pts.YArray.Length - 1
            Log(pts.YArray(i))
        Next
    Next
 
Upvote 0

giggetto71

Active Member
Licensed User
Longtime User
thanks @klaus I just did not know I could access the type defined inside a class from a library! that is just great info! thanks
 
Upvote 0
Top