Android Example Inputlist with images

Discussion in 'Tutorials & Examples' started by ilan, Apr 13, 2018.

  1. ilan

    ilan Expert Licensed User

    hi

    for one of my project, i needed an input list that includes images and i was thinking of using clv for that, but i really wanted to use the native input list so with CSBuilder it is very simple to archive.

    have fun!

    Screenshot_20180413-134929.jpg
     

    Attached Files:

    Last edited: Apr 13, 2018
    Pencil3, LucaMs, Jorge M A and 15 others like this.
  2. Mahares

    Mahares Well Known Member Licensed User

    Very nice example @ilan. The only thing I would change if I was doing it, is eliminate the ShortCur list and use this code:
    Code:
    InputListAsync(longCur, "Select Currency", -1True)
        
    Wait For InputList_Result (Index As Int)
        
    If Index <> DialogResponse.CANCEL Then
            
    Dim MySelection As String=longCur.Get(Index)
            MySelection=MySelection.SubString2(MySelection.IndexOf(
    "(")+1,MySelection.IndexOf(")"))
            
    Log("Selected Currency is: " & MySelection)  'yields same result as Ilan's
        End If
     
  3. ilan

    ilan Expert Licensed User

    the reason i have 2 lists is i use those currencies in other scenarios so i think it is more readable like this but as long as it works for you its ok :)
     
    Last edited: Apr 14, 2018
    Jorge M A and Levit like this.
  4. Jorge M A

    Jorge M A Member Licensed User

    Thank you very much @ilan for sharing this interesting and useful code on InputListAsync and at the same time of the CSBuilder!
    Since I was not able to decipher how did you get the constant factors of height and width of the image :(, I thought it appropriate to use the technique that @Erel suggests in this tutorial, to not distort the image.
    Do you think that is correct?

    Code:
    Dim bmp As Bitmap
        
    For x = 0 To longCur.Size-1
            
    Dim cs As CSBuilder
            
    'Original -> cs.Initialize.Image(LoadBitmap(File.DirAssets,"flags/cur" & x & ".png"),Activity.Width*0.07,Activity.Height*0.0225,True).Color(Colors.Black).Pop

            bmp = LoadBitmapResize(
    File.DirAssets, "flags/cur" & x & ".png"24dip24dipTrue)
            cs.Initialize.Image( bmp, bmp.Width, bmp.Height, 
    True).Color(Colors.Black).Pop
            
            cs.Color(
    Colors.Black).Append("     " & longCur.Get(x)).PopAll
            longCur.Set(x,cs)
        
    Next
    Thanks again!
     
  5. ilan

    ilan Expert Licensed User

    with my code, it should be shown the same on all devices because the size is related to the screen size this is the zoom effect where everywhere the app looks the same.
    this is not the best way to do. if you have a bigger screen you can do more but i find it much nicer to work like this. and until now i had no complains so my apps had no issues with a button is outside the frame or stuff like that because i use always the size related to the screen. i created an app in b4j where it is much simpler to get all x,y left, top of a view the is calculated to the screen size and i paste it into the designer script.
     
    Jorge M A 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