access listview in different module

rls456

Member
Licensed User
Longtime User
Access list in another activity

You cannot access a ListView that belongs to a different activity. While one activity is visible the other can be destroyed. You should store the data in a List as a process global object.

I had allready tried that but can not access the list in a different activity.
when i test the application i get an error that i need to initlize the list first.
I initilized the list in on create and still get the message.
I use Main.List = dosomething
 
Upvote 0

rls456

Member
Licensed User
Longtime User
There should be no problem accessing a List declared as a process global object in one module from another.
Please post your code if it doesn't work for you.

'Activity1 module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim VoiceNo As Int
Dim MyResult As String
Dim ListItems As List
End Sub

Activity2
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim EditText1 As EditText
Dim EditText2 As EditText
Dim label1 As Label
Dim label2 As Label
Dim EmailList As List

End Sub

" on button click"
Dim txt, item As String
Dim i As Int
txt = ""
For i =0 To EmailList.Size -1
item = EmailList.Get(i)
txt=txt&item&CRLF
Next
Label1.Text = txt
 
Upvote 0
Top