Android Question Asyncstream and UI access

Addo

Well-Known Member
Licensed User
Longtime User
is it safe to access UI such as listview in Newdata available directly ?

i know it is asynchronize i am asking this because i have tried to update UI inside NEWdata

and the phone freeze while adding items to Xcustomelistview i am adding about 100 items

thats how new data looks like

B4X:
Public Sub NewData (data() As Byte)
  
Dim msg As String

msg = BytesToString(data, 0, data.Length, "UTF-8")

Dim param As String = msg
Dim paramnum() As String = Regex.Split("\~", param)

For i = 0 To paramnum.Length-1
       XVIWLST.Add(CreateListItem(paramnum(i), XVIWLST.AsView.Width, 50dip), paramnum(i))
Next

End Sub
 

udg

Expert
Licensed User
Longtime User
Please have a look here.
I am not at my PC so I can't help better, sorry.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
is it safe to access UI such as listview in Newdata available directly ?
Yes.

I read some where here in forum that calling sleep in this matter will not avoid the blocking of the UI and its not useful in this manner
That's wrong.

Can you post the code in CreateListItem?
 
Upvote 0

Addo

Well-Known Member
Licensed User
Longtime User
sure here is my createlistitem
B4X:
Dim p As Panel
   p.Initialize("")
   p.SetLayout(0, 0, Width, Height)
   p.LoadLayout("cellitem")
   itemlabel.Text = text
   image1.Bitmap = LoadBitmap(File.DirAssets, "1.png")
   image2.Bitmap = LoadBitmap(File.DirAssets, "2.png")
   image3.Bitmap = LoadBitmap(File.DirAssets, "3.png")
   End If
  
   Return p
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…