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:
Code: Copy
b.setSingleChoiceItems(items, CheckedItem, dr);
with
Code: Copy
b.setItems(items, dr);
So in effect it just removes the RadioButtons from the InputList.

Sample code:

Code: Copy
   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

Thank you very much,
I never thought, I modified the code and now it works.
Bye
Nicola
Code: Copy
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
 
I am giving this a whirl as it may solve a problem I have been fighting over. Why is Cursor1 and Gene still red?

Code: Copy
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
 
What is the line below supposed to be ?
Code: Copy
Curcor1 As SQL
Shouldn't it be
Code: Copy
Dim Cursor1 As Cursor
What is this line supposed to do ?
Code: Copy
Gene = Array As String(ValoreGenere)
Where is Gene declared ?
You use Gebe as an array but ValoreGenere is a String ?

Best regards.
 
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
 
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
 
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!
 
Back
Top