B4J Tutorial 2 Tips: Animated Gifs and ListView items size

Discussion in 'B4J Tutorials' started by Erel, May 30, 2017.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Two tips learned while developing a custom SDK manager for B4A:

    [​IMG]

    1. I wanted to show an animated indicator while the external process runs. You can show a ProgressBar or ProgressIndicator with Progress set to -1 (indeterminate mode). However these modes should be avoided as they prevent the screen from updating properly.
    A better solution is to use an animated gif. I wasn't aware to the fact that JavaFX (B4J ui engine) natively supports animated gifs. This makes it very simple to add nice animations as regular images.

    2. The ListView items are made of panes with various layouts. You can see that if you resize the window the checkbox move and if the list is not wide enough then the version label moves under the description label. This is done with two layout variants.

    [​IMG]

    For the resizing to work the panes need to be resized when the ListView is resized:
    Code:
    Sub MainForm_Resize (Width As Double, Height As Double)
       
    For Each p As Pane In lstItems.Items
         p.SetSize(lstItems.Width - 
    40, p.Height) '-40 to provide space for the scroll bar
       Next
    End Sub
    I encountered an issue where the height of the items is not set correctly in some cases. The solution was to add a CSS file that explicitly set the height:
    Code:
    .list-cell {
      -fx-cell-size: 40px;
    }
     
    jroriz, paragkini and klaus like 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