B4J Question [B4X] How to change dropdown width

janderkan

Well-Known Member
Licensed User
Longtime User
Using B4XPreferencesDialog i would like to change the width of the dropdownbox in AddShortOptionsItem.
I am sure its easy, but I cannot figure it out.
 

janderkan

Well-Known Member
Licensed User
Longtime User
When I open the shortoptions layout from the designer it copies the file to my project and I can edit it.
What happens if I update B4R and get a new b4xlib, will it continue to use my file?

More specific: If there is a layoutfile in a B4Xlib and in the files folder, with the same name, the one in the files folder is always used?
 
Last edited:
Upvote 0

Quandalle

Member
Licensed User
Without changing the source code of the library, I use on my side the following routine (see changePosSpinner) to change the size of the spinner

example of size change
B4X:
    ...
    dim pfdAction As PreferencesDialog
    pfdDialog.Initialize(Activity,"Tittle",90%x, 290dip)
    pfdDialog.AddBooleanItem("item0","item 0 ")
    pfdDialog.AddSeparator("item1")
    pfdDialog.AddShortOptionsItem("item2","item2  : ",listShortOption)

    ' change the pos abd size of the spinner for item2
    changePosSpinner(pfDialog,2,100dip,212dip)
    ...
    
' index is the rank of the item in the preferenceDialog (from 0 = first item created)
Sub changePosSpinner ( pdia As PreferencesDialog, index As Int , left As Int , width As Int  )
    Dim p As Panel = pdia.CustomListView1.GetPanel(index)
    Dim p2 As Panel
    Dim s2 As Spinner
    
    p2 =  p.GetView(1)
    s2 = p2.GetView(0)
    p2.Left = left
    p2.Width = width
    s2.Width = width
End Sub

Of course the item must be identified by its rank, which imply that in case of a change in the order, the index must be updated in the call.
This routine can be improved by browsing all the items of the preferencesDialog to find the name of the item to be resized and then access from the name without being tied to the rank.
 
Upvote 0
Top