Android Question Views alignment in customlistview

Sub7

Active Member
Licensed User
Hello, i'm learning to use the customlistview and i don't understand how to aling and place a button in a proper way the result should be something like in the attached image.

Also i cannot find where to change the background color of the customlistview!

I want to align btnask to the right, by setting left as int it will move but is that the correct way?
i don't know exactly how many dips i have in different screens.

Excuse me for so many questions and errors in code.


B4X:
                        Dim textcontainer As Label
                        textcontainer.Initialize("")

                        Dim btnask As Button
                        btnask.Initialize("btnask")   
                       
 textcontainer.text = "Name: " &name& " - "&sent_date & CRLF & gender & CRLF & "Age: "&age & CRLF &"Comment: " &comment 
  
                        listpanel.AddView(btnask,300dip, 2dip, 50dip,50dip)
                        listpanel.AddView(textcontainer,1dip, 2dip, 300dip,300dip)
                        btnask.Width = 40dip
                        btnask.Height = 40dip
                        btnask.SetBackgroundImage(LoadBitmap(File.DirAssets, "askicon.png"))
                       
                        textcontainer.Width = pnlbackground.Width -80
                        userlist.DefaultTextBackgroundColor = Colors.RGB("28","28","28") 'does not works
                        userlist.DefaultTextColor = Colors.Black
                        userlist.Add(listpanel, 90dip,"")

Thank you very much
 

Attachments

  • customlistview.jpg
    customlistview.jpg
    14.4 KB · Views: 106

mangojack

Well-Known Member
Licensed User
on the Color question .. in the CLV class Process Globals you have 'RowColor' ..

the following code sets alternative row colors ..
in CLC class Process Globals
B4X:
rowColor1 = Colors.White
rowColor2 =  0xFFFFF8DC  'Cornsilk
textColor = Colors.Black
  
rowColorflag = False

then
B4X:
Sub  CreateList1(values()As String, width() As Int) As Panel
    
   'initialize new panel for row
   Dim p As Panel
   p.Initialize("")  
  
   'set alternative color
   Select rowColorflag
     Case False
       p.Color = rowColor1     'White
       rowColorflag = True
     Case True
       p.Color = rowColor2    'Cornsilk
       rowColorflag = False
   End Select

note .. just looking at this old code i'm sure theres a way to do that without the rowColorflag boolean.. (another day)
 
Upvote 0
Top