How to do away the buttons in customdialog..

ahwong

Member
Licensed User
Longtime User
I added a listview to the customdialog and I want it to return the listview item that I click. The dialog should be closed upon selection. How to do that?

Thanks in advance..

B4X:
Sub Globals
  Dim pos As Int
End Sub

Sub Activity_Create(FirstTime As Boolean)
  Dim btn As Button
  btn.Initialize("btn")
  btn.Text="click me"
  Activity.AddView(btn,0,0,100dip,50dip)
End Sub

Sub btn_Click
  Dim i As Int 
  Dim lv As ListView
  Dim cd As CustomDialog2
  lv.Initialize("lv")
  For i=0 To 99
    lv.AddSingleLine("Item : " & i)
  Next
  cd.AddView(lv, 77%x, 70%y)
  ret = cd.Show("B4A Custom Dialog", "", "OK", "", Null) + pos
  Msgbox(ret,"selection")
End Sub

Sub lv_ItemClick (Position As Int, Value As Object)
  pos = Position
End Sub
 

derez

Expert
Licensed User
Longtime User
Search "inputlist" and see this:
InputList (Items As List, Title As String, CheckedItem As Int) As Int

Shows a modal dialog with a list of items and radio buttons. Pressing on an item will close the dialog.
Returns the index of the selected item or DialogResponse.Cancel if the user pressed on the back key.
List - Items to display.
Title - Dialog title.
CheckedItem - The index of the item that will first be selected. Pass -1 if no item should be preselected.

It is a simple display like a spinner, not capable of different typeface for each item, but it does not require any layout definitions.
 
Last edited:
Upvote 0
Top