Android Question xCustomlistview & xGauges update value

mtselection

Member
Licensed User
Longtime User
Hi,

I try to use xCustomlistview with xGauges v 1.8 and the code is as follows:

B4X:
    Dim user As showtype
    Dim lbtest As String
    clv1.Clear
    If userdata.showlist.Size>0 Then
        Dim calc As Double
        Dim str As String
        For i=0 To userdata.showlist.Size-1
            Dim p As B4XView = xui.CreatePanel("")
            Dim width As Int = 100%x
            Dim height As Int
            user=userdata.showlist.Get(i)
            If user.viewtype>2 And user.viewtype<6 Then
                height = 25%y
                p.SetLayoutAnimated(0, 0, 0, width, height)
                p.Color=Colors.ARGB(255,39,116,124)
                xGauges1.Initialize(Me,"xgauges")
                xGauges1.AddToParent(p, 30dip, 0, GaugeWidth)
                ......

in update

B4X:
Sub updatedata (val As String)
    If userdata.showlist.Size>0 Then
        Dim data() As String
        data = Regex.Split(",", val)
        Dim v As Double
        Dim typ As showtype
        For i=0 To userdata.showlist.Size-1
            
            typ = userdata.showlist.Get(i)
            v=data(typ.byteindex)
            If typ.viewtype>2 And typ.viewtype<6 Then
                Dim pnl As B4XView = clv1.GetPanel(i)
                xGauges1 = pnl.GetView(0).Tag
                xGauges1.Value=v
                Dim lbl As Label = pnl.GetView(2)
                lbl.Text=v
            End If
        Next
    End If
End Sub

In debug I check the xGauges1 = pnl.GetView(0).Tag is null and
in XGauges1.Value=v I received this error:
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runGoodChain(Shell.java:479)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:293)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)

Thanks
Maurizio
 

mtselection

Member
Licensed User
Longtime User
Thanks Erel,Klaus

I use this code in update:

B4X:
                Dim pnl As B4XView = clv1.GetPanel(i)
                For Each v As B4XView In pnl.GetAllViewsRecursive
                    If v.Tag Is xGauges Then
                        v.Tag.As(xGauges).Value = d
                    End If
                Next

but the v.Tag not return the xGauges class instance.

During the xclv creation I add 1 xGauges and 2 Labels, but this code return 3 panels (of xGauges), 2 labels and no Tag.

Thanks
Maurizio
 
Upvote 0

mtselection

Member
Licensed User
Longtime User
Ok, solved

code in creation:

B4X:
            Dim p As B4XView = xui.CreatePanel("")
            Dim width As Int = 100%x
            Dim height As Int
            user=userdata.showlist.Get(i)
            If user.viewtype>2 And user.viewtype<6 Then
                height = 25%y
                p.SetLayoutAnimated(0, 0, 0, width, height)
                p.Color=Colors.ARGB(255,39,116,124)
                Dim xgau As xGauges
                xgau.Initialize(Me,"xgauges")
                xgau.AddToParent(p, 30dip, 0, GaugeWidth)
                p.Tag=xgau
                xgau.BackgroundColor=Colors.Transparent

code in update:

B4X:
        Dim data() As String
        data = Regex.Split(",", val)
        Dim d As Double
        Dim typ As showtype
        For i=0 To userdata.showlist.Size-1
            typ = userdata.showlist.Get(i)
            d=data(typ.byteindex)
            If typ.viewtype>2 And typ.viewtype<6 Then
                Dim pnl As B4XView = clv1.GetPanel(i)
                Dim xgau As xGauges = pnl.Tag
                xgau.Value = d
                Dim lbl As Label = pnl.GetView(2)
                lbl.Text=d
            End If
        Next

Maurizio
 
Upvote 0
Top