B4A Class [B4A] DOListDialog - simple and customisable class

DOListDialog is a free class that makes it easy to display a list dialog.

Features:
- Easy to use: supply a title and a list and you're good to go.
- Auto-size the dialog to the minimum width or height needed, or leave it full-size.
- Show or hide the Cancel button as needed.
- Customize the visual layout by editing familiar component views.
- Free to use or modify (as long as you credit me as the original developer).
- Requires no additional libraries.

Still to do:
- Add support for the abstract designer.
- Auto-adapt to the current device theme (e.g. dark mode).
- Check compatibility with B4XPages (which I haven't tried yet - guessing it won't be hard).
- Add support for XUI (haven't gone there yet).

Background:
I needed to show a list to the user, and was surprised to find that most (all?) of the various dialog libraries didn't include a list dialog, or provided something close but not quite what I was looking for [edit: didn't know about InputListAsync - see below]. B4XDialog has a flexible custom dialog with a list template, but its variable naming conflicted with my code, so I decided to roll my own.

Demo app and class attached. Cheers!

standard dialog.png
customized dialog.png
 

Attachments

  • DOListDialog demo.zip
    14.2 KB · Views: 129
Last edited:

peacemaker

Expert
Licensed User
Longtime User
Why not ?:
    Dim options As List = Array("Red", "Green", "Blue")
    InputListAsync(options, "Select Color", 0, False)
    Wait For InputList_Result (Index As Int)
    If Index <> DialogResponse.CANCEL Then
        Log("Selected color: " & options.Get(Index))
    End If
Why not ?
 

JohnC

Expert
Licensed User
Longtime User
I have the same issue - other list libs needed to be anchored to another view, but I need something that can be display in the center of any screen.

Looking forward to the B4X version to work in B4i.
 

Dave O

Well-Known Member
Licensed User
Longtime User
InputListAsync(options, "Select Color", 0, False)

@peacemaker , that's strange, I've been using B4A for 10 years, and I've never seen this function before! I usually look for components by typing "dim someView as ..." and looking for classes that pop up, or searching the forums, but that one has escaped me somehow even though it's a built-in function like Msgbox.

With that said, I did give it a try now and it mostly does the job, but I do like having a visible Cancel button and ability to style the text (e.g. bold line 1, non-bold line 2), so looks like rolling my own was still worth it for me. :)
 

AnandGupta

Expert
Licensed User
Longtime User
so looks like rolling my own was still worth it for me.
It is always worth to have more than one choice.
Just look around the Forum and you see, Experts releasing so many similar but different views.
We all thank them, as many like me, are novice in this field.
 
Top