Android Code Snippet CustomLayoutDialog with CustomListView

Discussion in 'Code Snippets' started by Erel, Jul 30, 2017.

  1. Erel

    Erel Administrator Staff Member Licensed User

    [​IMG]

    1. Create a layout file with a CustomListView. Make sure that the CLV is anchored to all sides:

    [​IMG]

    2. Create the dialog:

    Code:
    Sub Activity_Click
       
    Dim cd As CustomLayoutDialog
       cd.ShowAsync(
    "Choose item"""""""NullFalse)
       cd.SetSize(
    100%x100%y'request maximum size
       Wait For Dialog_Ready (DialogPanel As Panel)
       DialogPanel.LoadLayout(
    "CustomDialogLayout")
       
    For i = 1 To 20
         CLVDialog.AddTextItem(
    "Item #" & i, i)
       
    Next
       
    Wait For CLVDialog_ItemClick (Index As Int, Value As Object)
       
    Log("Selected item: " & Value)
       cd.CloseDialog(
    DialogResponse.POSITIVE)
    End Sub
     

    Attached Files:

    Last edited: Jul 30, 2017
    scsjc, MarkusR, ocalle and 11 others like this.
  2. fredo

    fredo Active Member Licensed User

    The CustomLayoutDialog is really helpful since it is now really easy to create "fancy" dialogs via the Visual designer.

    But how could we dismiss it if the user taps BACK?

    Code:
    Sub Globals
        
    Dim cd As CustomLayoutDialog
            ...
    end sub

    Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
        Select KeyCode
            
    Case KeyCodes.KEYCODE_BACK
                cd.CloseDialog(
    DialogResponse.CANCEL)
                
    Return True
        
    End Select
    End Sub
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Change the Cancelable parameter to True:
    Code:
    cd.ShowAsync("Choose item"""""""NullTrue)
     
    ocalle, Johan Hormaza and fredo like this.
  4. Johan Hormaza

    Johan Hormaza Active Member Licensed User

    Excellent @Erel works very well with the new xCustomView.:)
     
  5. Patrick Clark

    Patrick Clark Member Licensed User

    How does it work with xCustomView. I cannot get it to add items.
     
    hibrid0 likes this.
  6. hibrid0

    hibrid0 Active Member Licensed User

    I have an old app with xcustomview and not show items. Any update? If I add customelistview not show items, if I compile the sample work fine.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    Check CLV text color. It is probably white over white.
     
    hibrid0 likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice