Loading various data types into listview

CharlesR

Member
Licensed User
Longtime User
I have declared a type as below:

Type Pipedata( diam As Int, temp As Int, length As Double, flanges As Int, valves As Int)
Dim Pipe As Pipedata
Dim Pipelist As List
Dim Pipeview As ListView

I want to add the data to a listview (pipeview in 5 columns) but I cant see how to do that.

Please could someone post a code snippet to demonstrate.

Many thanks

Charles
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

CharlesR

Member
Licensed User
Longtime User
Thanks Erel. Maybe I did not explain well enough. In this bit of my app (running on a 10 inch tablet) the user enters 5 sets of information using spinners on the top third of the screen. There will be between 5 and 20 records of pipe data which I want to show in horizontal lines in the lower 2/3 of the screen. Additionally, the user needs to be able to select a previously entered data set for correction if required. I am not sure of the best way to do this (or how I would code it?)

Thanks in advance.

Charles
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

CharlesR

Member
Licensed User
Longtime User
Thank you for your help. I am trying to take your code and add it to my app, and now I have my list in a scrollview, but I cannot see how to identify if a row has been touched. I tried to follow your selectitem, but I would be grateful if someone could tell me what exactly what event i am looking for i.e. is it a click and is it in the panel, scrollview or list. In other words having got my list into a scrollview, what identifies that a row has been selected?

Thanks in advance.

Charles
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Could you upload your code, it would be much easier to help you if we know exactly what and how you have setup the scrollview. You need to set the Tag parameter for each View correctly to know which one has raised an event.

Best regards.
 
Upvote 0

CharlesR

Member
Licensed User
Longtime User
Thanks for your help. I am new to the visual methods being more used to older languages, but this routine successfully loads my data into a list and shows it in a view. I would be grateful for any of your comments on my methods as well as showing me how to identify the data set which is touched.

Many thanks

Charles


Sub Savepipeschk_CheckedChange(Checked As Boolean)
Pipeview.RemoveView
If Savepipeschk.Checked Then
Pipe.diam = tpdiam
Pipe.temp = tptemp
Pipe.length = tplength
Pipe.flanges = tpflange
Pipe.valves = tpvalve
Pipelist.Add(Pipe)
'ToastMessageShow(Pipelist.Size,False)
Pipeview.SingleLineLayout.ItemHeight = 30dip
Pipeview.AddSingleLine("Diam " & Pipe.diam & " Temp " & pipe.temp & " Length " &pipe.length & " Flanges " & Pipe.flanges & " Valves " & Pipe.valves)
ScrollView1.Panel.AddView(Pipeview, 5dip, 15dip, ScrollView1.Width - 10dip, 190dip)
End If
End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Here you are ! :)

To populate the ScrollView you schouldn't use the ListView.
To be able to get the selected value (cell) you must add Labels to the ScrollView, one for each value in the Pipe variable.
One row for each Pipe

Attached you have a test program with your Pipe type variable.

Best regards.
 

Attachments

  • ScrollViewList2.zip
    7.2 KB · Views: 253
Upvote 0

CharlesR

Member
Licensed User
Longtime User
Thank you very much. That is just what I want. I shall try to incorporate it into my code today.

Thanks again!

Charles
 
Upvote 0

CharlesR

Member
Licensed User
Longtime User
Thanks again. I have incorporated your code into my app, but I have a couple of questions:

1. When you initialize something with (0) following, what does this do?
2. I have failed to incorporate List_Delete to remove one row.
3. I only want the scrollview present when Tabhost1 = 2. Where and how should I activate and remove it?

I would be very grateful for your help on these last few points. I am sorry if they are newbie questions, but I am still in my first month of B4A.

Many thanks

Charles
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
1. When you initialize something with (0) following, what does this do?
I think you are speaking of:
scvList.Initialize(0)
The number 0 is the height of the internal Panel. In this case I put 0 because the height is set afterwords according to the number of items. I could have given 100, but this value is never really used because it is changed just after filling the ScrollView.

2. I have failed to incorporate List_Delete to remove one row.
You find the routine in the attached program.

3. I only want the scrollview present when Tabhost1 = 2. Where and how should I activate and remove it?
The attached example program uses two TabHost panels. You need to add either a layoutfile or views to the TabHost panels, both possibilities are shown.

Best regards.

EDIT: 2011.05.01 replaced program, fixed an error
 

Attachments

  • ScrollViewList3.zip
    8.7 KB · Views: 222
Last edited:
Upvote 0

CharlesR

Member
Licensed User
Longtime User
Thank you very much indeed. I don't have time to incorporate the code for a couple of days but I am sure I will be fine from here on. I will let you know when I have done it. With a community like this B4A is bound to succeed.

Once again thank you for your patience and help.

Best Regards

Charles
 
Upvote 0
Top