Android Question problem when use same time costum list view & location

Tayfur

Well-Known Member
Licensed User
Longtime User
My code has Erel's costum listview.
(https://www.b4x.com/android/forum/t...xible-list-based-on-scrollview.19567/#content)

and I added Location manager v.1.1. I learningn geo coordinates from cell.

normaly only clistview in my code >>> work.
normaly only location manager in my code>>> work.

Same time working costumlistwev and Locationa manager.>> NOT work
it is broken when it works "Sub etiket_Click"


B4X:
#Region  Project Attributes
    #ApplicationLabel: example
    #VersionCode: 1
    #VersionName: start
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    '#SupportedOrientations: unspecified
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: TRUE
    #IncludeTitle: False
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
       
    Dim clv1 As control_view
    Dim clv3 As control_view
    Private Button1 As Button
    Private CheckBox1 As CheckBox
    Private Spinner1 As Spinner
    Dim Location As LocationManager

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Location.Initialize("Location")
    Activity.LoadLayout("L1")

   
End Sub

Sub clv3_ItemClick(Index As Int, Value As Object)
    Log(Index & " = " & Value)
End Sub

Sub CreateListItem2(Text As String, Width As Int, Height As Int, phonelist As List) As Panel
    Dim p As Panel
    p.Initialize("")
    p.Color = Colors.Black
    Dim b As Button
    b.Initialize("button") 'all buttons click events will be handled with Sub Button_Click
    Dim chk As CheckBox
    chk.Initialize("chk")
    Dim lbl As Label
    lbl.Initialize("etiket")
   
    Dim spn As Spinner
    Dim spn2 As Spinner
    spn.Initialize("spn")
    spn2.Initialize("spn2")
    spn.AddAll(phonelist)
    spn2.AddAll(Array As String("bey","hanım","ablacağım","abiciğim","kardeşim","kuzenim","yeğenim","amcacağım","dayıcığım","halacığım","teyzeciğim", "yengeciğim","dedeciğim","nineciğim","babananeciğim", "anneanneciğim"))
    lbl.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
    lbl.Text = Text
    lbl.TextSize = 16
    lbl.TextColor = Colors.White
    b.Text = "Click"
    'p.AddView( l - T w- h
    p.AddView(chk, 5dip, 2dip, 50dip, Height - 4dip) 'view #0
    p.AddView(lbl, 55dip, 2dip, 165dip, Height - 4dip) 'view #1
    p.AddView(spn, 220dip, 2dip, 170dip, Height - 4dip) 'view #2
    p.AddView(spn2, 390dip, 2dip, 150dip, Height - 4dip) 'view #3
    Return p
End Sub



Sub Activity_Resume
    Location.requestMobileLocation
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub



Sub Button1_Click
    ' scrool vieww için hazırlanmış
    '  https://www.b4x.com/android/forum/threads/class-customlistview-a-flexible-list-based-on-scrollview.19567/#content
    'https://www.b4x.com/android/forum/threads/scrollview-examples-summary.8423/#content
   
    ProgressDialogShow("Rehberiniz okunuyor ve listeleniyor...")
    DoEvents
   
    '********************* SMS GÖNDERME VE ARAMA *****************************************
    'Dim xcall As PhoneCalls
    'Dim xsms As PhoneSms
    'xsms.Send("+905335135121","2 sistemm çalıstı")
    'StartActivity( xcall.Call("02127711379"))
    '********************* SMS GÖNDERME VE ARAMA *****************************************
   
   
    Dim c As Contact
    Dim cs As Contacts2
    '-------------Liste düzenleme-------------------
    clv3.Initialize(Me, "clv3")
    Activity.AddView(clv3.AsView, 0, 30%y, 100%x, 70%y)
    Dim phonelist As List
    phonelist.Initialize
    '----------------------------------
          Dim l As List
          l = cs.GetAll(True,True)
        Dim telf As Map
        'Msgbox(l.Size, "kişi sayısı")
          For i = 0 To l.Size - 1
            c = l.Get(i)
            telf= c.GetPhones
            phonelist.Clear
            For z=0 To telf.size-1
                phonelist.Add(telf.GetKeyAt(z))   
            Next
            clv3.Add(CreateListItem2( c.DisplayName, clv3.AsView.Width, 40dip,phonelist), 40dip, c.Id)
            Log( c.DisplayName)
        Next 
    ProgressDialogHide
   
   
    ' formatting using embedded tokens and the RichTextFormatter
    Dim rs As RichString
    Dim rsf As RichStringFormatter
    rs.Initialize("{R}{T}{Blue}This2{Blue}{T}{R} {U}is{U} one more {Red}{BI}Rich{Red}String{BI}")
    rsf.Initialize("{sample}")
   
   
    rsf.AddToken("{R}", rsf.FORMAT_RELATIVESIZE, 1.5)
    rsf.AddToken("{T}", rsf.FORMAT_TYPEFACE, "serif")
    rsf.AddToken("{Blue}", rsf.FORMAT_COLOR, Colors.Blue)
    rsf.AddToken("{Red}", rsf.FORMAT_COLOR, Colors.Red)
    rsf.AddToken("{U}", rsf.FORMAT_UNDERSCORE, Null)
    rsf.AddToken("{BI}", rsf.FORMAT_STYLE, rsf.STYLE_BOLD_ITALIC)
    rs = rsf.Format(rs)
    'Label3.Text = rs
   
End Sub

Sub spn2_ItemClick (Position As Int, Value As Object)
    Msgbox("2 ci","")
End Sub
Sub spn_ItemClick (Position As Int, Value As Object)
    Dim index As Int
    index = clv3.GetItemFromView(Sender)
    Dim pnl As Panel
    pnl = clv3.GetPanel(index)
    Dim spn,spn2 As Spinner
   
    Dim lbl As Label
    Dim chk As CheckBox
   
    lbl = pnl.GetView(1)
    spn = pnl.GetView(2)
    chk = pnl.GetView(0)
    spn2 = pnl.GetView(3)
    lbl.Text = "telfon!"
    Msgbox("Item value: " & clv3.GetValue(index) & CRLF & "spinner value: " & spn.GetItem(Position), "")
End Sub

Sub chk_CheckedChange(Checked As Boolean)
    Dim index As Int
    index = clv3.GetItemFromView(Sender)
    Dim pnl As Panel
    pnl = clv3.GetPanel(index)
    Dim chk As CheckBox
    chk = pnl.GetView(0)
    'Msgbox("Item value: " & clv3.GetValue(index) & CRLF & "Check value: " & chk.Checked, "")
    etiket_Click
End Sub

Sub etiket_Click
Dim index As Int
    index = clv3.GetItemFromView(Sender)
    Dim pnl As Panel
    pnl = clv3.GetPanel(index)
   
    Dim lbl As Label
    Dim chk As CheckBox
    lbl = pnl.GetView(1)
    chk = pnl.GetView(0)
    'Msgbox(lbl.Tag,"")
    If chk.Checked=True Then
   
    Dim st,bt As String
    Dim rs As RichString
    Dim rs2 As RichString
    'Dim sf As StringFunctions
    'Dim rsf As RichStringFormatter
    rs2.Initialize(lbl.Text)
    
     Dim ANS As List
     Dim sf As StringFunctions
    ANS = sf.Split(lbl.Text, " ")
    If lbl.Tag=Null Then lbl.Tag=0
    If lbl.Tag=ANS.Size Then lbl.Tag=0
    If ANS.Size=1 Then
        rs2.Color(Colors.Red,0,lbl.Text.Length)
    Else
        st=""
        For i=0 To (lbl.Tag-1)
            st=st&ANS.Get(i)&" "
        Next
        bt=st&ANS.get(lbl.Tag)
        If lbl.Tag+0=0 Then
         st=""
         bt=ANS.get(lbl.Tag)
        End If
        rs2.Color(Colors.Red,st.Length,bt.Length)
        lbl.Tag=(lbl.Tag*1)+1
    End If
    lbl.Text =rs2
    st=st
    Else
    ' temiz yazar
   
    lbl.Text=lbl.Text
    lbl.Tag=Null
    End If
    'rs.Initialize("{R}{T}{Blue}This2{Blue}{T}{R} {U}is{U} one more {Red}{BI}Rich{Red}String{BI}")
    'rsf.Initialize("{sample}")
    'rsf.AddToken("{R}", rsf.FORMAT_RELATIVESIZE, 1.5)
    'rsf.AddToken("{T}", rsf.FORMAT_TYPEFACE, "serif")
    'rsf.AddToken("{Blue}", rsf.FORMAT_COLOR, Colors.Blue)
    'rsf.AddToken("{Red}", rsf.FORMAT_COLOR, Colors.Red)
    'rsf.AddToken("{U}", rsf.FORMAT_UNDERSCORE, Null)
    'rsf.AddToken("{BI}", rsf.FORMAT_STYLE, rsf.STYLE_BOLD_ITALIC)
    'rs = rsf.Format(rs)
    'lbl.Text =" tamam 2 dır"

End Sub


Sub Button_Click
    Dim index As Int
    index = clv3.GetItemFromView(Sender)
    Dim pnl As Panel
    pnl = clv3.GetPanel(index)
   
    Dim lbl As Label
    Dim chk As CheckBox
    lbl = pnl.GetView(1)
    chk = pnl.GetView(0)
    lbl.Text = "Clicked!"
    Msgbox("Item value: " & clv3.GetValue(index) & CRLF & "Check value: " & chk.Checked, "")
End Sub


Sub CheckBox1_CheckedChange(Checked As Boolean)
    If Checked=True Then
            Msgbox("chek edilidi","")
        Else 
            Msgbox("iptal","")
        End If
        etiket_Click
End Sub
Sub Spinner1_ItemClick (Position As Int, Value As Object)
    Msgbox( Spinner1.GetItem(Position),"")
End Sub


Sub Location_LocationChanged (Longitude As Double, Latitude As Double, Altitude As Double, Accuracy As Float, Bearing As Float, Provider As String, Speed As Float, Time As Long)
Log("demnene")
'ToastMessageShow("Long: " & Longitude & " - Lat: " & Latitude,True)
Log("Long: " & Longitude & " - Lat: " & Latitude)
'Msgbox("Long: " & Longitude & " - Lat: " & Latitude  & "Accuracy = " & Accuracy & Chr(10) & "Bearing = " & Bearing &Chr(10) & "Provider="& Provider &Chr(10)&"Speed="& Speed&Chr(10) &"Time=" & Time, "")
End Sub

Sub Location_ProviderDisabled (Provider As String)
'ToastMessageShow("Location_ProviderDisable: " & Provider, True)
Log("Location_ProviderDisable: " & Provider)
End Sub

Sub Location_ProviderEnabled (Provider As String)
'ToastMessageShow("Location_ProviderEnabled: " & Provider, True)
Log("Location_ProviderEnabled: " & Provider)
End Sub

Sub Location_StatusChanged (Provider As String, Status As Int)
'ToastMessageShow("Location_StatusChanged: " & Provider & " Status: " & Status, True)
Log("Location_StatusChanged: " & Provider & " Status: " & Status)
End Sub

costum listwiew


B4X:
'version: 1.10
#Event: ItemClick (Index As Int, Value As Object)
Sub Class_Globals
    Private sv As ScrollView
    Private items As List
    Private panels As List
    Private dividerHeight As Float
    Private pressedDrawable As Object
    Private EventName As String
    Private CallBack As Object
    Private su As StringUtils
    Public DefaultTextSize As Int
    Public DefaultTextColor As Int
    Public DefaultTextBackgroundColor As Int
    Private DefaultTextBackground As Object
End Sub


Public Sub Initialize (vCallback As Object, vEventName As String)
    sv.Initialize2(0, "sv")
    items.Initialize
    panels.Initialize
    dividerHeight = 2dip
    EventName = vEventName
    CallBack = vCallback
    sv.Color = 0xFFD9D7DE 'this sets the dividers color
    Dim r As Reflector
    Dim idPressed As Int
       idPressed = r.GetStaticField("android.R$drawable", "list_selector_background")
    r.Target = r.GetContext
    r.Target = r.RunMethod("getResources")
    pressedDrawable = r.RunMethod2("getDrawable", idPressed, "java.lang.int")
    DefaultTextColor = Colors.White
    DefaultTextSize = 16
    DefaultTextBackgroundColor = Colors.Black
    DefaultTextBackground = Null
End Sub

'Returns a view object that holds the list.
Public Sub AsView As View
    Return sv
End Sub

Public Sub DesignerCreateView(base As Panel, lbl As Label, props As Map)
    Dim parent As Panel
    Dim r As Reflector
    r.Target = base
    parent = r.RunMethod("getParent")
    base.RemoveView 'remove the base panel
    parent.AddView(sv, base.Left, base.Top, base.Width, base.Height)
    DefaultTextSize = lbl.TextSize
    DefaultTextColor = lbl.TextColor
    DefaultTextBackground = base.Background
End Sub

'Clears all items.
Public Sub Clear
    items.Clear
    panels.Clear
    sv.Panel.Height = 0
    For i = sv.Panel.NumberOfViews - 1 To 0 Step -1
        sv.Panel.RemoveViewAt(i)
    Next
End Sub



'Returns the number of items.
Public Sub GetSize As Int
    Return items.Size
End Sub

'Returns the Panel stored at the specified index.
Public Sub GetPanel(Index As Int) As Panel
    Dim p As Panel
    p = panels.Get(Index) 'this is the parent panel
    Return p.GetView(0)
End Sub

'Returns the value stored at the specified index.
Public Sub GetValue(Index As Int) As Object
    Return items.Get(Index)
End Sub

'Removes the item at the specified index.
Public Sub RemoveAt(Index As Int)
    Dim removePanel, p As Panel
    removePanel = panels.Get(Index)
    For i = Index + 1 To items.Size - 1
        p = panels.Get(i)
        p.Tag = i - 1
        p.Top = p.Top - removePanel.Height - dividerHeight
    Next
    sv.Panel.Height = sv.Panel.Height - removePanel.Height - dividerHeight
    items.RemoveAt(Index)
    panels.RemoveAt(Index)
    removePanel.RemoveView
End Sub

'Adds a text item. The item height will be adjusted based on the text.
Public Sub AddTextItem(Text As String, Value As Object)
    InsertAtTextItem(items.Size, Text, Value)
End Sub

'Inserts a text item at the specified index.
Public Sub InsertAtTextItem(Index As Int, Text As String, Value As Object)
    Dim pnl As Panel
    pnl.Initialize("")
    Dim lbl As Label
    lbl.Initialize("")
    lbl.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
    pnl.AddView(lbl, 5dip, 2dip, sv.Width - 5dip, 20dip)
    lbl.Text = Text
    lbl.TextSize = DefaultTextSize
    lbl.TextColor = DefaultTextColor
    If DefaultTextBackground <> Null Then
        pnl.Background = DefaultTextBackground
    Else
        pnl.Color = DefaultTextBackgroundColor
    End If
    Dim minHeight As Int
    minHeight = su.MeasureMultilineTextHeight(lbl, Text)
    lbl.Height = Max(50dip, minHeight)
    InsertAt(Index, pnl, lbl.Height + 2dip, Value)
End Sub

'Adds a custom item at the specified index.
Public Sub InsertAt(Index As Int, Pnl As Panel, ItemHeight As Int, Value As Object)
   
    Dim sd As StateListDrawable
    sd.Initialize
    sd.AddState(sd.State_Pressed, pressedDrawable)
    sd.AddCatchAllState(Pnl.Background)
   
    'create another panel to handle the click event
    Dim p As Panel
    p.Initialize("panel")
    p.Background = sd
    Dim cd As ColorDrawable
    cd.Initialize(Colors.Transparent, 0)
    Pnl.Background = cd
    p.AddView(Pnl, 0, 0, sv.Width, ItemHeight)
    p.Tag = Index
   
    If Index = items.Size Then
        items.Add(Value)
        panels.Add(p)
        Dim top As Int
        If Index = 0 Then top = dividerHeight Else top = sv.Panel.Height
        sv.Panel.AddView(p, 0, top, sv.Width, ItemHeight)
    Else
        Dim top As Int
        If Index = 0 Then
            top = dividerHeight
        Else
            Dim previousPanel As Panel
            previousPanel = panels.Get(Index - 1)
            top = previousPanel.top + previousPanel.Height + dividerHeight
        End If

        Dim p2 As Panel
        For i = Index To panels.Size - 1
            p2 = panels.Get(i)
            p2.top = p2.top + ItemHeight + dividerHeight
            p2.Tag = i + 1
        Next
        items.InsertAt(Index, Value)
        panels.InsertAt(Index, p)
        sv.Panel.AddView(p, 0, top, sv.Width, ItemHeight)
    End If
    sv.Panel.Height = sv.Panel.Height + ItemHeight + dividerHeight
    If items.Size = 1 Then sv.Panel.Height = sv.Panel.Height + dividerHeight
End Sub

'Adds a custom item.
Public Sub Add(Pnl As Panel, ItemHeight As Int, Value As Object)
    InsertAt(items.Size, Pnl, ItemHeight, Value)
End Sub

'Scrolls the list to the specified item.
Public Sub JumpToItem(Index As Int)
    Dim top As Int
    Dim p As Panel
    For i = 0 To Min(Index - 1, items.Size - 1)
        p = panels.Get(i)
        top = top + p.Height + dividerHeight
    Next
    sv.ScrollPosition = top
    'The scroll position doesn't always gets updated without two calls to DoEvents
    DoEvents
    sv.ScrollPosition = top
    DoEvents
End Sub

Private Sub Panel_Click
    If SubExists(CallBack, EventName & "_ItemClick") Then
        Dim v As View
        v = Sender
        CallSub3(CallBack, EventName & "_ItemClick", v.Tag, items.Get(v.Tag))
    End If
End Sub

'Returns the index of the item that holds the given view.
Public Sub GetItemFromView(v As View) As Int
    Dim r As Reflector
    Dim parent, current As Object
    parent = v
    Do While (parent Is Panel) = False Or sv.Panel <> parent
        current = parent
        r.Target = current
        parent = r.RunMethod("getParent")
    Loop
    v = current
    Return v.Tag
End Sub





B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
demnene
Long: 28.6404656 - Lat: 41.0905137
phone name1
phone name12
phone name13
phone name14
phone name51
phone name16
phone name17
Long: 28.6404656 - Lat: 41.0905139
demnene
Long: 28.6404657 - Lat: 41.0905139
Error occurred on line: 212 (control_view)
java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2
    at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
    at java.util.Arrays$ArrayList.get(Arrays.java:66)
    at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
    at b4a.example.main._etiket_click(main.java:749)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
    at android.view.View.performClick(View.java:4232)
    at android.view.View$PerformClick.run(View.java:17298)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4921)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
    at dalvik.system.NativeStart.main(Native Method)
 

Tayfur

Well-Known Member
Licensed User
Longtime User
picture is under below.
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    67.5 KB · Views: 350
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
It is a different module. It happens in the main module.
sorry... i cant understant.


*****************************
module :: "control_view" is your costum listview. (https://www.b4x.com/android/forum/th...xible-list-based-on-scrollview.19567/#content) Not change it
+
"Location manager" library.

*************************************************************

Now I changed code,

first step; "Locatioan manager" library very 15sec run "Sub Location_LocationChanged ..."
I changed code. And I add locationmanager.stoprequest when LM read firt time . After LM stopped run "Sub Location_LocationChanged ..."

second step;
I add the code to a lot of places in "Sub etiket_Click" (label_clik)

now I cant recive error.

But; why I revice error?? i think problem is (getparent) ????
But your are expert.
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You should use ContactUtils to get the contacts list and you most probably need to only take the "visible" contacts. The current method you use is too slow.

This is the error line:
B4X:
 bt=st&ANS.get(lbl.Tag)

You need to check the code and find out why you are trying to get index #2 when there are only 2 items in this list.
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
You should use ContactUtils to get the contacts list and you most probably need to only take the "visible" contacts. The current method you use is too slow.

This is the error line:
B4X:
bt=st&ANS.get(lbl.Tag)

You need to check the code and find out why you are trying to get index #2 when there are only 2 items in this list.


I will use your code.

I woeked this problem code last night. and I found somethings. I cheked step by step. I find a interesting thing when it broke code.
"Getitemfromview (it is your costum scrollview)" sub has a working time is null or chekbox or animations...,

on broke time, it has a GPS location. and after ruining code is broke.

İ think problem is Location maneger. Because LM is working 1 time every 15sec. Your wiew and Lm crash. this is my idea?
how am i fix it?

Error picture.jpg
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
This is most probably the the problem: "This code will not work if you call this sub as Sender will not be set" (correctly).

Thank you for your feedback. so I am not expert :(

My code is under below when broken time.
I press first checkbox; afterr recive error/broke.

Plese some code for fixing

B4X:
Sub chk_CheckedChange(Checked As Boolean) ' chechkbox click event on listview

Dim index As Int
    index = clv3.GetItemFromView(Sender)
    Dim pnl As Panel
    pnl = clv3.GetPanel(index)
    Dim chk As CheckBox
    chk = pnl.GetView(0)
    Dim spn As Spinner
    spn = pnl.GetView(2)
    Dim spn2 As Spinner
    spn2 = pnl.GetView(3)
'—my codess….
    etiket_Click '<<<--------- Problem ????  Code go to "Sub etiket_Click" (But, I dont push label)
End Sub


Sub etiket_Click ' Label click event on listview
DoEvents
DoEvents
Dim index As Int
    DoEvents
    DoEvents
    index = clv3.GetItemFromView(Sender) '<<< code go to modole and it run "Public Sub GetItemFromView(v As View) As Int"
    Dim pnl As Panel
    pnl = clv3.GetPanel(index)
 
    Dim lbl As Label
    Dim chk As CheckBox
    lbl = pnl.GetView(1)
    chk = pnl.GetView(0)
'—my codes
End Sub


'---Erels code Costumlistview  module
' this your listviews Erel’s code
'Returns the index of the item that holds the given view.
Public Sub GetItemFromView(v As View) As Int
    Dim r As Reflector
    Dim parent, current As Object
    parent = v
    DoEvents
    Do While (parent Is Panel) = False Or sv.Panel <> parent
        current = parent
        r.Target = current
        parent = r.RunMethod("getParent") '<<<<-----BORKEN CODE
    Loop
    v = current
    Return v.Tag
End Sub
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
You can only use the Sender keyword when the sub is executed as a result of an event. If you call the sub in your code then you shouldn't use sender.
Erel please please some code; because I am not expert.
i use first time "r.RunMethod" and reflaction. therefore I cant understandt your way /words.

please some code... :(
my projects is stop.
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
It has nothing to do with r.RunMethod.

The problem is here:
index = clv3.GetItemFromView(Sender)

You expect Sender to hold the view that raised the event. This will not be the case when the checkbox is checked. You can create a new method that accepts a single View parameter and pass Sender to this sub.

CODE OR SAMPLE ??? I hate reflection.
Your description is adequate for someone who knows better of the B4A program / reflection /Java.
So, I only looko_O:confused:o_O:confused:o_O:confused:o_O:confused:o_O
:( :(:(:(:(
 
Last edited:
Upvote 0
Top