CustomListView - A flexible list based on ScrollView

Status
Not open for further replies.

DonManfred

Expert
Licensed User
Longtime User
but i get a compile error:

B4X:
Error compiling program.
Error description: Current declaration does not match previous one.
Previous: {Type=Phone,Rank=0}
Current: {Type=Panel,Rank=0}

You have DIM an object p as panel. But you previously dim a p as phone
 

GMan

Well-Known Member
Licensed User
Longtime User
How can i get the content of the (GetView(0)) in the lower CLV3 ( i.e. the text "Item #9") ?
SS-2012-07-15_17.59.22.png
 

GMan

Well-Known Member
Licensed User
Longtime User
Thx...you made my day :)
 

GMan

Well-Known Member
Licensed User
Longtime User
..and how works this with a "normal" ListView ?
There i want to get the second.label - Text

The getPanel is not allwoed with that :-(
 

DonManfred

Expert
Licensed User
Longtime User
..and how works this with a "normal" ListView ?
There i want to get the second.label - Text

The getPanel is not allwoed with that :-(

You can store any info you like in the listviews "Item Value"

See this example

B4X:
Dim retmap As Map
retmap.Initialize
retmap.Put("tag","TagValue"&i)
retmap.Put("itemID","ItemID"&i)
retmap.Put("name","ItemName"&i)
retmap.Put("line1","This is line 1")
retmap.Put("line2","This is line 2")
lv.AddTwoLines2(retmap.Get("line1"), retmap.Get("line2"), retmap)

B4X:
Sub lv_ItemClick (Position As Int, Value As Object)
    Dim retmap As Map
    retmap = Value
    Log("Item at Pos "&Position&" Clicked...")
    Log("ItemInfos:")
    Log("tag = "&retmap.Get("tag"))
    Log("itemID = "&retmap.Get("itemID"))
    Log("name = "&retmap.Get("name"))
    Log("line 1 = "&retmap.Get("line1"))
    Log("line 2 = "&retmap.Get("line2"))
End Sub
 

Attachments

  • listviewtest.zip
    7.5 KB · Views: 278
Last edited:

GMan

Well-Known Member
Licensed User
Longtime User
Thx for the Sample, Manfred - i'll try.
the project couldnt be opened, because i am still using iDE 2.71.
(seems that i have to save some money for an update)
 

GMan

Well-Known Member
Licensed User
Longtime User
Jepp, made the bal-file new
 

DAM

Member
Licensed User
Longtime User
Hello!
First of all, I'm sorry if I ask a question which was already answered, but I couldn't find.
I use Erel's example to make my own CustomListView with data from database. Everything is working fine but... the customlistview is not scrolling.
You can see in the picture that the last item is cut and it is not possible to scroll. What could be the problem??
Thanks a lot for your help!!

B4X:
scrollCimentacion.Initialize(200dip)
scrollCimentacion.Color=Colors.white
pan.AddView(scrollCimentacion,0%x, 8%y, 100%x, 100%y)    scrollCimentacion.Panel.LoadLayout("cimentacion")
If File.ExternalWritable = False Then
    sql1.Initialize(File.DirInternal, "ite.s3db", False)
Else
    sql1.Initialize(File.DirRootExternal, "ite.s3db", False)
End If
cursor1=sql1.ExecQuery("select nombre from elemento where id_padre=95")
clvcontencion.Initialize(Me, "clv2")
            pnlContencion.AddView(clvcontencion.AsView, 0, 0, pnlContencion.Width, pnlContencion.Height)
For i = 0 To cursor1.RowCount -1
    cursor1.Position=i         
clvcontencion.Add(CreateListItem(cursor1.GetString("nombre"), clvcontencion.AsView.Width, 50dip), 50dip, cursor1.GetString("nombre"))
Next       
scrollCimentacion.Panel.Height= 150%y


On the Designer the panel (pnlContencion) in which I add my customlistview is 280 height.
 

Attachments

  • Screenshot_2014-05-17-19-50-31.png
    Screenshot_2014-05-17-19-50-31.png
    28.2 KB · Views: 328

DAM

Member
Licensed User
Longtime User
What is the purpose of scrollCimentacion?

Hello!
Sorry I didn't explain my self in a better way:
-I have a ViewPager and each page has a scrollview:

B4X:
Dim pan As Panel
        Select i
            Case 0
                pan= CreatePanel(CIMENTACION, "Cimentación")
                container.AddPage(pan,"Cimentación")
....

B4X:
Sub CreatePanel(PanelType As Int, Title As String) As Panel
    Dim pan As Panel
    Dim pi As PanelInfo
  
    pi.Initialize
    pi.LayoutLoaded = False
    pi.PanelType = PanelType

    pan.Initialize("")
    Select PanelType
        Case CIMENTACION
            scrollCimentacion.Initialize(400dip)
            scrollCimentacion.Color=Colors.white
            pan.AddView(scrollCimentacion,0%x, 8%y, 100%x, 100%y)
       scrollCimentacion.Panel.LoadLayout("cimentacion")

Etcetera (what I added yesterday)

I don't know why the customlistviews are not scrolling...
 

DAM

Member
Licensed User
Longtime User
I don't completely understand your code. Make sure that there is no transparent view over the CustomListView. If you are unable to solve it then please upload your project.

Thanks a lot, I wanted to upload my code but it is very large, so I paste here Dropbox link:
https://www.dropbox.com/s/sj4g9ykdj8tsspg/tecni_ite.zip

My apologies because it's not clean and it's not very good, still in progress.
The customlistviews are in "elementos" module.

(By the way, as you will see, each panel of the customlistview has a label, togglebutton and checkbox. I want to change the order, making: label + checkbox + togglebutton. When I do this, it happens an error, I attached a picture).

Thank you so so much for your help!!
Greetings
 

Attachments

  • error_cast.JPG
    error_cast.JPG
    90 KB · Views: 172

DAM

Member
Licensed User
Longtime User
Yes, it is.
I see the point... So the solution could be to have a panel instead of a scrollview in the page, right? In that case, the problem could be that if the content doesn't fit in the panel (phone screen), user could not be able to scroll it :(


Thanks a lot for the time you spare on it!
 
Status
Not open for further replies.
Top