Android Question [CLOSED] Passing Views to a service using lists ?

lemonisdead

Well-Known Member
Licensed User
Hello,

I am asking the question because of the idea of @DonManfred about removing a view from a service and his warning about me adding another view again and again.

So, aware of the fact I couldn't declare views from as Process_Globals, I have tried to use lists : a Globals list to add the created view and a Process_Globals one to add the view got from the previous list.

Like this :

B4X:
Sub Process_Globals
    Dim L1 As List
End Sub

Sub Globals
    Dim mView As Label
    Dim L As List
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If Not(L.IsInitialized) Then L.Initialize
    If Not(L1.IsInitialized) Then L1.Initialize

    If FirstTime Then
        mView.Initialize("")
        mView.Text= "Some text"
        L.Add(mView)
        L1.Add(L.Get(0))
    End If

End Sub
Then on a service I think I can get the reference to the view

B4X:
Sub AddOverlay
    Dim mView As Label
    mView.Initialize("")
    mView=Main.L1.Get(0)
    ...
End Sub
This works. But could you please, tell me if I am really getting a reference to the View that I had declared in the Main Globals ? (This to be able to study how to use removeView later).

Many thanks
 
Top