Android Question Not able to control Button height & Width at CustomlistView

AndroidMadhu

Active Member
Licensed User
Hello,
I have created the button dynamically. But not able to control the width and height of the button at customListView.
Below is my code snippet
B4X:
Sub Process_Globals
    Dim xui As XUI
End Sub

Sub Globals
    
    Private CLV1 As CustomListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Main")
    'CLV1.DefaultTextBackgroundColor=Colors.Gray
    For i = 0 To 100
        CLV1.Add(createItem("Item #" & i,CLV1.AsView.Width,200dip),i)   
    Next

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

private Sub createItem(Text As String,width As Int,height As Int) As B4XView
    Dim p As B4XView=xui.CreatePanel("")
    Dim btnxpan As Button
    btnxpan.Initialize("")
    p.SetLayoutAnimated(0,0,0,100%x,10%x)
    p.Color=Colors.White
    Dim lbl As Label
    lbl.Initialize("")
    lbl.Text=Text
    lbl.TextColor=Colors.Black
    p.AddView(lbl,12dip,10dip,100dip,100dip)
    btnxpan.Color=Colors.Gray
    btnxpan.TextColor=Colors.Black
    btnxpan.Width=70%x
    btnxpan.Text=Text
    p.AddView(btnxpan,90%x,10dip,10dip,10dip)
    Return p
End Sub

Please suggest
 

AndroidMadhu

Active Member
Licensed User
Where is you item click event in which you are trying to control the button?
I just wanted to place the button on customlistview and trying to increase the height and width of the button.

Later I will add the click event for operations
 
Upvote 0

AndroidMadhu

Active Member
Licensed User
My suggestion is to create a layout for the cells. You will then be able to use anchors and designer script and it will be much simpler.
@Erel definitely I will try your suggestion.

Meantime Fixed the same with the below code....
B4X:
p.AddView(btnxpan,CLV1.AsView.Width-55dip,10dip,50dip,height-4dip)

But not able to place any text on the button for example "Click" or "OK" something like that. Any clue please?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…