M MikeGOTO Member Nov 16, 2020 #1 Is there a relatively easy way to populate and scroll a ListView (or any other view) from the bottom up? I am reading UDP Packets of GPS data and want to display the most recent 10 entries; self-scrolling. It would look very similar to the log display while compiling/running from the B4A IDE. I have been searching the forum and experimenting for several days with no luck. I did see a third party presented "UltimateListView", but I would like to stick with standard code. I also need to remove all but the last 50 or so entries. The UDP stream produces a huge amount of data, and never stops. I envision memory problems if overloading. I have been attempting CustomListView1.RemoveAt(i), with a rolling counter, but no real success. Forgive me if this is a trivial question - I will likely be asking a few. Other then a little VBA, this is my first foray into OOP. FORTRAN, well there is a language I can speak. Visual FORTRAN - now that's an idea...
Is there a relatively easy way to populate and scroll a ListView (or any other view) from the bottom up? I am reading UDP Packets of GPS data and want to display the most recent 10 entries; self-scrolling. It would look very similar to the log display while compiling/running from the B4A IDE. I have been searching the forum and experimenting for several days with no luck. I did see a third party presented "UltimateListView", but I would like to stick with standard code. I also need to remove all but the last 50 or so entries. The UDP stream produces a huge amount of data, and never stops. I envision memory problems if overloading. I have been attempting CustomListView1.RemoveAt(i), with a rolling counter, but no real success. Forgive me if this is a trivial question - I will likely be asking a few. Other then a little VBA, this is my first foray into OOP. FORTRAN, well there is a language I can speak. Visual FORTRAN - now that's an idea...
Erel B4X founder Staff member Licensed User Longtime User Nov 16, 2020 #2 MikeGOTO said: The UDP stream produces a huge amount of data, and never stops. Click to expand... How will the user scroll such list? Are you showing anything other than text? Upvote 0
MikeGOTO said: The UDP stream produces a huge amount of data, and never stops. Click to expand... How will the user scroll such list? Are you showing anything other than text?
M MikeGOTO Member Nov 17, 2020 #3 The intent is to load latest data (all text) to the bottom of the view, automatically scrolling everything up one element. There is a Pause/Resume button that closes the UDPSocket. When paused the user should be able to drag down, scrolling to previous entries (up to a memory imposed limit). Again, it should look and work very similar to the log view on the B4A IDE. If there is a better view to accomplish this, I am totally open. Upvote 0
The intent is to load latest data (all text) to the bottom of the view, automatically scrolling everything up one element. There is a Pause/Resume button that closes the UDPSocket. When paused the user should be able to drag down, scrolling to previous entries (up to a memory imposed limit). Again, it should look and work very similar to the log view on the B4A IDE. If there is a better view to accomplish this, I am totally open.
Erel B4X founder Staff member Licensed User Longtime User Nov 17, 2020 #4 If it is just text then it might be simpler to use EditText or BBCodeView, though xCLV is also good. MikeGOTO said: Is there a relatively easy way to populate and scroll a ListView (or any other view) from the bottom up? Click to expand... Create a tall empty item and add it as the first item. Later add items with CLV.Add and scroll to the bottom. Upvote 0
If it is just text then it might be simpler to use EditText or BBCodeView, though xCLV is also good. MikeGOTO said: Is there a relatively easy way to populate and scroll a ListView (or any other view) from the bottom up? Click to expand... Create a tall empty item and add it as the first item. Later add items with CLV.Add and scroll to the bottom.
M MikeGOTO Member Nov 18, 2020 #5 Regarding use of CLV, did you mean CLV.AddText rather than CLV.Add? I am only loading text, so I do not understand "Create a tall empty item and add it as the first item". I have seen EditView suggested as a view for lists, but I cannot seem to make it display more than a single item. How might this look? many thanks Upvote 0
Regarding use of CLV, did you mean CLV.AddText rather than CLV.Add? I am only loading text, so I do not understand "Create a tall empty item and add it as the first item". I have seen EditView suggested as a view for lists, but I cannot seem to make it display more than a single item. How might this look? many thanks
Erel B4X founder Staff member Licensed User Longtime User Nov 18, 2020 #6 MikeGOTO said: Regarding use of CLV, did you mean CLV.AddText rather than CLV.Add? Click to expand... Both options are good. MikeGOTO said: I am only loading text, so I do not understand "Create a tall empty item and add it as the first item". Click to expand... Code: Copy Dim p As B4XView = xui.CreatePanel("") p.SetLayoutAnimated(0, 0, 0, 600dip, CLV.AsView.Width) CLV.Add(p, "") Upvote 0
MikeGOTO said: Regarding use of CLV, did you mean CLV.AddText rather than CLV.Add? Click to expand... Both options are good. MikeGOTO said: I am only loading text, so I do not understand "Create a tall empty item and add it as the first item". Click to expand... Code: Copy Dim p As B4XView = xui.CreatePanel("") p.SetLayoutAnimated(0, 0, 0, 600dip, CLV.AsView.Width) CLV.Add(p, "")
M Mahares Expert Licensed User Longtime User Nov 18, 2020 #7 Erel said: p.SetLayoutAnimated(0, 0, 0, 600dip, CLV.AsView.Width) Click to expand... Shouldn't this be like this: Code: Copy p.SetLayoutAnimated(0, 0, 0, CLV.AsView.Width, 600dip) Are you getting overwhelmed like us now. Upvote 0
Erel said: p.SetLayoutAnimated(0, 0, 0, 600dip, CLV.AsView.Width) Click to expand... Shouldn't this be like this: Code: Copy p.SetLayoutAnimated(0, 0, 0, CLV.AsView.Width, 600dip) Are you getting overwhelmed like us now.
M MikeGOTO Member Nov 18, 2020 #8 Definitely confused. I am not certain if I am fumbling my question, or if putting a simple, scrolling, text-only, read-only, list of messages is as complicated as it seems. I have not yet got as far as understanding the XUI library or what B4XView is all about. Is there a simple way to do this with the views available in the Designer? I keep seeing EditView mentioned as an easy option, but I cannot get it to load more than a single item. EditView does not seem to have index or scrolling control. I want to list 10 messages, newest to the bottom, oldest scrolling off the top; just like the log display in the IDE. Upvote 0
Definitely confused. I am not certain if I am fumbling my question, or if putting a simple, scrolling, text-only, read-only, list of messages is as complicated as it seems. I have not yet got as far as understanding the XUI library or what B4XView is all about. Is there a simple way to do this with the views available in the Designer? I keep seeing EditView mentioned as an easy option, but I cannot get it to load more than a single item. EditView does not seem to have index or scrolling control. I want to list 10 messages, newest to the bottom, oldest scrolling off the top; just like the log display in the IDE.
Erel B4X founder Staff member Licensed User Longtime User Nov 19, 2020 #9 I highly recommend you to learn about XUI and B4XView. 1. They are very simple to use. 2. Almost all new features are based on them. B4X Programming Video Tutorials www.b4x.com Make sure that the EditText SingleLine property is unchecked. Upvote 0
I highly recommend you to learn about XUI and B4XView. 1. They are very simple to use. 2. Almost all new features are based on them. B4X Programming Video Tutorials www.b4x.com Make sure that the EditText SingleLine property is unchecked.
M MikeGOTO Member Nov 19, 2020 #10 I will dive into XUI and B4XView. In the meantime, Yes on: EditText1.SingleLine=False On every event - UDP_PacketArrived I populate the EditText: msg = BytesToString(Packet.Data, Packet.Offset, Packet.Length, "UTF8") msg=msg.SubString2(0,18) EditText1.=msg The message is displayed at the bottom of the EditView, but each subsequent message overlays the previous. Only one message displayed at a time. I seems to be missing something - probably simple, but important. Upvote 0
I will dive into XUI and B4XView. In the meantime, Yes on: EditText1.SingleLine=False On every event - UDP_PacketArrived I populate the EditText: msg = BytesToString(Packet.Data, Packet.Offset, Packet.Length, "UTF8") msg=msg.SubString2(0,18) EditText1.=msg The message is displayed at the bottom of the EditView, but each subsequent message overlays the previous. Only one message displayed at a time. I seems to be missing something - probably simple, but important.
Erel B4X founder Staff member Licensed User Longtime User Nov 20, 2020 #12 Code: Copy EditText1.Text = EditText1.Text & CRLF & msg Upvote 0
M MikeGOTO Member Nov 20, 2020 #13 That does it. So a multi-line EditView is a single text string with embedded CRLFs. Thank you very much. I will research the XUI and B4XPages if I need to pretty it up. Upvote 0
That does it. So a multi-line EditView is a single text string with embedded CRLFs. Thank you very much. I will research the XUI and B4XPages if I need to pretty it up.