Android Question Some help (pnl = lst.FindPanelContaining(Sender))

PABLO2013

Well-Known Member
Licensed User
Longtime User
greetings, would like some help : (CheckList v2.22)

My intention is to change content of a text view by a seekbar (in a panel or another) from a list of panels, but it gives me error.

This is the creation of views:

B4X:
Sub CreateItem(h, i As Int) As Panel
        Dim pnl As Panel, lbl As Label, chk As CheckBox, edt As EditText,sb As StartPointSeekBar
     
        Dim indexa As Int
     
        pnl.Initialize("")

        chk.Initialize("ChkBx") 'View #0
        pnl.AddView(chk, 0, 0, 40dip, h)
     
     
        sb.Initialize("sb") 'View #1
        sb.TheRangeColor = Colors.Red
        sb.Tag=indexa
        sb.TheBackgroundColor = Colors.Cyan
'        sb.TheRangeColor = 0xFF33B5E5
        sb.MinValue = -9                    'Keep the order of this 3 lines of code
        sb.maxValue = 9
        sb.ThumbValue = 0
        sb.SetColorAnimated(300,2323,343345)
        pnl.AddView(sb, 150, 15, 250dip, 50dip)
     
'     
        lbl.Initialize("") 'View #2
        lbl.Text = "Alternativa #" & i
        lbl.TextColor = Colors.White
        lbl.TextSize = 18
        lbl.Gravity = Gravity.CENTER_VERTICAL
        pnl.AddView(lbl, 45dip, 0, lst.getWidth - 130dip, h)
             
     
        edt.Initialize("") 'View #3
        edt.Visible = True
        edt.Hint = "Qty"
        edt.InputType = edt.INPUT_TYPE_NUMBERS
        pnl.AddView(edt, 500dip, 1dip, 80dip, h)
        Return pnl
End Sub

This work well:

B4X:
Sub ChkBx_CheckedChange(Checked As Boolean)
    Dim pnl As Panel
    pnl = lst.FindPanelContaining(Sender)
    Dim edt As EditText
    edt = pnl.GetView(3)
    edt.Text = 1

End Sub

This is what does not work:

B4X:
Sub sb_value_changed

Dim pnl As Panel
pnl = lst.FindPanelContaining(Sender)

Dim edt As EditText
edt = pnl.GetView(3)
edt.Text = 1


End Sub


In the module CheckList this is the code it generates is common error ( as I see in some posts )

B4X:
Private Sub GetParentPanel(MyView As View) As View
    Dim r As Reflector
    Dim v, Parent As View
    r.Target = MyView
    v = r.Target
    Parent = r.RunMethod("getParent")
    Do While Parent <> sv.Panel
        r.Target = Parent
        v = r.Target
        Parent = r.RunMethod("getParent")
    Loop
    Return v

End Sub

The error log is:

java.lang.ClassCastException: anywheresoftware.b4a.ShellBA cannot be cast to android.view.View
at flm.chklist.test.main._sb_value_changed(main.java:858)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
...
attartpointseekbarwrapper.startPointSeekBarWrapper$1.value_changed(startPointSeekBarWrapper.java:72)
...


The problem is that I have no knowledge to solve thanks in advance
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…