Android Question How do I add manually Value on Custom List View?

darkz

Member
B4X:
Mnu_List.Add(MenuListItems("asd",Mnu_List.AsView.Width, 60dip),60dip,1)

Sub MenuListItems (Text As String, Width As Int, Height As Int, Value As Object) As Panel
Dim p As Panel
    p.Initialize("")
    p.Color = Colors.White
    p.SetLayout(0,0,Width,Height)
    p.LoadLayout("test_menuitems")
    mnu_lbl.Text = Text
    Value = Value
    Return p
    
    End Sub

Im having error in the Value part
 
Solution
Im having error in the Value part

B4X:
Mnu_List.Add(MenuListItems("asd",Mnu_List.AsView.Width, 60dip) ,  "My Value For This CLV Item")   ' Value  As Object , so can be anything (Value of i , Map, List etc)

Sub MenuListItems (Text As String, Width As Int, Height As Int) As Panel ' Do not include Value as a parameter here,  it is a Parameter of the Mnu_List.Add Sub Signiture.
Dim p As Panel  ' could be loaded another way with xui lib...
    p.Initialize("")
    p.Color = Colors.White
    p.SetLayout(0,0,Width,Height)
    p.LoadLayout("test_menuitems")
    mnu_lbl.Text = Text
    'Value = Value  ' ##### Remove !
    Return p
    End Sub


How about this i want the Mnu_List to have a fewer cells but its fixed to 7 counts in...

darkz

Member
But what is this?
try this:
B4X:
Mnu_List.Add(MenuListItems("asd",Mnu_List.AsView.Width, 60dip,""),1)
B4A Version: 12.20
Parsing code. (0.02s)
Java Version: 8
Building folders structure. (0.02s)
Running custom action. (0.05s)
Compiling code. Error
Error compiling program.
Error description: ')' expected.
Error occurred on line: 95
Mnu_List.Add(MenuListItems("asd",Mnu_List.AsView.Width, 60dip,""),1)
Word: ,

i get this as an error
 
Upvote 0

darkz

Member
B4X:
    Dim p1 As Panel
    Dim p2 As Panel
    Dim p3 As Panel
    Dim p4 As Panel
    Dim p_menu As Panel


For i = 0 To 6
       
       
       p_menu.Initialize("")
       p_menu.SetLayout(0,0,100%x,50dip)
       p_menu.LoadLayout("test_menuitems")
       
           
       
       
        p1.Initialize("")
        p1.SetLayout(0,0,60dip,150dip)
        p1.LoadLayout("test_cell_items")
       
        p2.Initialize("")
        p2.SetLayout(0,0,100%x,150dip)
        p2.LoadLayout("test_cell_items2")
       
        p3.Initialize("")
        p3.SetLayout(0,0,100%x,150dip)
        p3.LoadLayout("test_cell_items3")
       
        p4.Initialize("")
        p4.SetLayout(0,0,100%x,150dip)
        p4.LoadLayout("test_cell_items4")
       
        Week1Lv.Add(p1,i)
        Week2Lv.Add(p2,i)
        Week3Lv.Add(p3,i)
        Week4Lv.Add(p4,i)
        Mnu_List.Add(p_menu,i)

How about this i want the Mnu_List to have a fewer cells but its fixed to 7 counts in all clv
 
Last edited:
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Im having error in the Value part

B4X:
Mnu_List.Add(MenuListItems("asd",Mnu_List.AsView.Width, 60dip) ,  "My Value For This CLV Item")   ' Value  As Object , so can be anything (Value of i , Map, List etc)

Sub MenuListItems (Text As String, Width As Int, Height As Int) As Panel ' Do not include Value as a parameter here,  it is a Parameter of the Mnu_List.Add Sub Signiture.
Dim p As Panel  ' could be loaded another way with xui lib...
    p.Initialize("")
    p.Color = Colors.White
    p.SetLayout(0,0,Width,Height)
    p.LoadLayout("test_menuitems")
    mnu_lbl.Text = Text
    'Value = Value  ' ##### Remove !
    Return p
    End Sub


How about this i want the Mnu_List to have a fewer cells but its fixed to 7 counts in all clv
Have we even solved your first problem ? and your throwing in another issue ( Start a New Thread for a New Question)

But while I'm here , maybe this might be the culprit.
B4X:
For i = 0 To 6  'try 0 to 3  OR 1 to 4
 
Last edited:
Upvote 2
Solution

darkz

Member
Thank You Sir it works like a charm
 
Upvote 0

darkz

Member
About the other question what I mean is that I'm using a single "for i" in multiple CLV and I wanted them to have a different row count so that I could use the "for i" for the value while I can choose how many cell to show on different CLV
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
About the other question what I mean is that I'm using a single "for i" in multiple CLV and I wanted them to have a different row count so that I could use the "for i" for the value while I can choose how many cell to show on different CLV

Not understanding well exactly what you want to do.
Start a new Thread for this question and Upload a small sample project .

Comment the project well (and especially the loading loop) , to make it clear to others exactly what your trying to achieve.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…