B4A Library Popup Menu/List Library

What it does:
Shows an InputList modal dialog and allows the user to select an item from the list and hides on selection of the item.

Why we may need it:
This will eventually become redundant as Erel adds it to the Core library.
I needed to show some popup menus, and experimented with various ideas (panels, inputlist etc) but none were perfect. This should take care of screen size, modality etc in the same way other dialogs do.

How it works:
Nothing great. I just copied the function InputList from the Core library and replaced:
B4X:
b.setSingleChoiceItems(items, CheckedItem, dr);
with
B4X:
b.setItems(items, dr);
So in effect it just removes the RadioButtons from the InputList.

Sample code:

B4X:
   Dim r As List 
   r.Initialize 
   r.AddAll(Array As String("Download","Upload","Share"))
   
   Dim x As id 
   m = x.InputList1(r,"Hello")
   Msgbox(m,"Result")
 

Attachments

  • id.zip
    2.5 KB · Views: 2,220

cnicolapc

Active Member
Licensed User
Thank you very much,
I never thought, I modified the code and now it works.
Bye
Nicola
B4X:
Sub BtnGenere_CLick
Dim r As List 
r.Initialize 
Dim x As id 
Dim m As Int
Dim responseString As String


    
    Dim ValoreGenere As String
    Dim r As List
    r.Initialize 
    
    ListaGenere.Initialize("ListaGenere")
    Cursor1 = Main.Sql1.ExecQuery("SELECT Genere FROM GenereTab Order By Genere ASC")
    For i = 0 To Cursor1.RowCount - 1
        Cursor1.Position = i
        ValoreGenere=Cursor1.GetString("Genere")
        If ValoreGenere.Length >=30 Then
        ValoreGenere=ValoreGenere.SubString2(0,30)&"..."
        End If
        ValoreGenere=ValoreGenere.Replace(Chr(13), " ")
        ValoreGenere=ValoreGenere.Replace(Chr(10), " ")
        
      
        r.Add(ValoreGenere)
            
       Next

    m = x.InputList1(r,"Hello")
Msgbox(m,"Result Integer")
responseString = r.Get(m)
Msgbox(responseString,"Result String")
    

        End Sub
 

roarnold

Active Member
Licensed User
I am giving this a whirl as it may solve a problem I have been fighting over. Why is Cursor1 and Gene still red?

B4X:
Dim r As List 
               r.Initialize 
               Dim x As id 
               Dim m As Int
               Dim responseString As String


                   Dim  ListaGenere As List
                   Dim ValoreGenere As String
                  Curcor1 As SQL 
                   Dim r As List
                   r.Initialize 
                   
                   ListaGenere.Initialize("ListaGenere")
                   Cursor1 = Main.Sql1.ExecQuery("SELECT Genere FROM GenereTab Order By Genere ASC")
                   For i = 0 To Cursor1.RowCount - 1
                       Cursor1.Position = i
                       ValoreGenere=Cursor1.GetString("Genere")
                       If ValoreGenere.Length >=30 Then
                       ValoreGenere=ValoreGenere.SubString2(0,30)&"..."
                       End If
                       ValoreGenere=ValoreGenere.Replace(Chr(13), " ")
                       ValoreGenere=ValoreGenere.Replace(Chr(10), " ")
                       
                       Gene = Array As String(ValoreGenere)
                       r.Add(Gene)
                           
                      Next

               m = x.InputList1(r,"Hello")
               Msgbox(m,"Result Integer")
               responseString = r.Get(m)
               Msgbox(responseString,"Result String")

Thanks,
R
 

klaus

Expert
Licensed User
What is the line below supposed to be ?
B4X:
Curcor1 As SQL
Shouldn't it be
B4X:
Dim Cursor1 As Cursor
What is this line supposed to do ?
B4X:
Gene = Array As String(ValoreGenere)
Where is Gene declared ?
You use Gebe as an array but ValoreGenere is a String ?

Best regards.
 

shashkiranr

Active Member
Licensed User
Hi Thedesolatesoul,

Thank you so much just what i needed. i wanted the popup to be in the middle and since i had only one item in the list. Works Beautifully :) :)

Regards,
SK
 

socialnetis

Active Member
Licensed User
Excellent! This is what I was looking for.
How strange that this is not part of the core library yet. Or at least I didn't find it
 

Javier Alonso

Member
Licensed User
Hi,

I would like to have the "id" library adapted to the InputListAsync method, if possible, to make menus with a simple inputlist. I have been using the feature widely and I would like to migrate to async. Thanks in advance!
 
Top