Android Question B4XDialog B4XListTemplate Non Scrolling List

bocker77

Active Member
Licensed User
Longtime User
I can't seem to figure out how I can have all of the items in the customlistview show without scrolling. I also do not need the button area at the bottom of the dialog. Is there a way of doing this within the confines of a B4XListTemplate? Everything I try doesn't work. Thanks for any help.

B4X:
    lstPowers.Initialize
    lstPowers.AddAll(Array As String("Germany", "Soviet Union", "Japan","United States","China", _
                                     "UK Europe", "UK Pacific", "Italy", "ANZAC", "France"))
    TemplateDlg.Initialize(Root)
    TemplateDlg.PutAtTop = True
    TemplateDlg.Title = csMsgTitle
    TemplateDlg.TitleBarHeight = 50dip
    TemplateDlg.TitleBarColor = Steel
    TemplateDlg.BackgroundColor = xui.Color_Black
    TemplateDlg.BorderWidth = 10
    TemplateDlg.BorderColor = Steel
    TemplateDlg.BorderCornersRadius = 10
    TemplateDlg.Base.Height = 800dip     ' just seeing if this has any effect
    tmpList.Initialize
    tmpList.Options = lstPowers
    tmpList.CustomListView1.DesignerLabel.Typeface = fntMsgNormal
    tmpList.CustomListView1.PressedColor = xui.Color_RGB(126, 180, 250)
    tmpList.CustomListView1.DefaultTextBackgroundColor = Colors.Black
    tmpList.CustomListView1.DefaultTextColor = xui.Color_White
    tmpList.CustomListView1.sv.ScrollViewInnerPanel.Color = xui.Color_Red
    tmpList.AllowMultiSelection = False
    ...    
    Dim rs As ResumableSub = TemplateDlg.ShowTemplate(tmpList,  "", "", "")
    Wait For (rs) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        For i = 0 To tmpList.SelectedItems.size - 1
            strPower = tmpList.SelectedItems.Get(i)
        Next
    End If
 

bocker77

Active Member
Licensed User
Longtime User
Actually I am changing my code to use a custom dialog using B4XRadioButtons. I have it working but would like to be able to continue after selecting a radio button without needing to use a button at the bottom to close the dialog. Is this possible? I was able to do that with the list in the first post.

Or do I need to create a new post for this question.

Thanks!

B4X:
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, 325dip, 450dip)
p.LoadLayout("Powers")
Wait For (Dialog.ShowCustom(p, "", "", "")) Complete (Result As Int)
If Result = xui.DialogResponse_Positive Then   <<<< Never gets here
    Log(strPower)
End If
...
Private Sub SelectPower_Checked
    Dim v As B4XRadioButton
    v = Sender
    strPower = v.text
End Sub
 
Upvote 0

teddybear

Well-Known Member
Licensed User
I'm not really sure what you're going to do, all of the items in the customlistview are shown without scrollbar, and close dialog when a item is selected.
is it the result you want?

微信图片_20240718235523.jpg
 
Upvote 0

bocker77

Active Member
Licensed User
Longtime User
Sorry I didn't reply to you sooner but yes that is what I initialy was looking for. I have since created a layout with radio buttons and am using a custom dialog. See post #3 for code. It would be nice if the dialog would end once a radio button is selected instead of having to press the dialog's button at the bottom. If you have any suggestions on how to do that I would much appreciate it.

Thanks!
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Try this code, perhaps it is what you want.

B4X:
    tmplist.Initialize
    tmplist.Resize(300dip,533dip)
    tmplist.Options = lstpowers
'    tmplist.CustomListView1.DesignerLabel.Typeface = fntMsgNormal
    tmplist.CustomListView1.PressedColor = XUI.Color_RGB(126, 180, 250)
    tmplist.CustomListView1.GetBase.Height=533dip
'    tmplist.CustomListView1.DefaultTextBackgroundColor =XUI. Colors.Black
    tmplist.CustomListView1.DefaultTextColor = XUI.Color_White
    tmplist.CustomListView1.sv.ScrollViewInnerPanel.Color = XUI.Color_Red
    tmplist.AllowMultiSelection = False
'    ...
    Dim rs As ResumableSub = Dialog.ShowTemplate(tmplist,  "", "", "")
    Wait For (rs) Complete (Result As Int)
    If Result = XUI.DialogResponse_Positive Then
        For i = 0 To tmplist.SelectedItems.size - 1
            Log(tmplist.SelectedItems.Get(i))
            XUI.MsgboxAsync(tmplist.SelectedItems.Get(i), "You selected")
        Next
    End If
 
Upvote 0

bocker77

Active Member
Licensed User
Longtime User
Thanks again for replying but after entering good search words on the forum I have figured it out. Problem solved!

B4X:
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, 325dip, 450dip)
    p.LoadLayout("Powers")
    Dialog.ButtonsHeight = 0
    Dim rs As ResumableSub = Dialog.ShowCustom(p, "", "", "")
    Wait For (rs) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
       ....
    End If

Private Sub SelectPower_Checked
    Dim v As B4XRadioButton
    v = Sender
    iPowerNumber = v.tag
    strPower = v.text
    Dialog.Close(xui.DialogResponse_Positive)
End Sub
 
Upvote 0
Top