B4A Library [Library] ComboBox

melamoud

Active Member
Licensed User
Longtime User
using the combobox inside a dialog

hi,

I have problems when I try to put the combobox inside a dialog,
1. click an item does not do anything, only when the show ends it call the module itemclick sub (I guess this is part of the be modal issues, but the click to open the list works, if you can fix it that the click on the item will close the list and copy the text to the editbox that will be great (I do not need the event)
2. if I have other items on the dialog below the coombo box the list appear under the other items (I have a text box) - can you fix that as well ?

thanks
 

melamoud

Active Member
Licensed User
Longtime User

and a feature request, can you add setText method ? so I wont need to add the text to the list and choose it as default - thanks
 

HotShoe

Well-Known Member
Licensed User
Longtime User


Odd, all of my devices work properly when an item is clicked. It closes the dropdown and fills in the text box with the selected item.

I have updated the library to make it alwats display the dropdown on top now. Thanks for reminding me.

--- Jem
 

HotShoe

Well-Known Member
Licensed User
Longtime User
and a feature request, can you add setText method ? so I wont need to add the text to the list and choose it as default - thanks

Great idea, and I have added it to this version (1.23).

Thanks,

--- Jem
 

melamoud

Active Member
Licensed User
Longtime User
Its working in activity but not when added to a modal dialog can you check?

Thanks

Sent from my SCH-I545 using Tapatalk 2
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Its working in activity but not when added to a modal dialog can you check?

Thanks

Sent from my SCH-I545 using Tapatalk 2

Do you have some sample code that does not work? I don't know how you are defining modal dialog, but it works in activities and panels here. I need more information to find the problem.

--- Jem
 

melamoud

Active Member
Licensed User
Longtime User
here it is

B4X:
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(a As activity)
   Dim nd As CustomDialog
   Dim lblFpath As Label
   lblFpath.Initialize("")
   lblFpath.Text = "test"
   
   
   Dim p As Panel
   p.Initialize("")
   nd.AddView(p,0,0,100%x,100%y)
         
   p.AddView(lblFpath,0,0,100%x,20%y)
         
   Dim edt_Author As MLComboBox
   edt_Author.Initialize(a, Me, p, "edtAuthor")
   
      
   edt_Author.DropColor(Colors.Red) 'uncomment these to test colors and text size
   edt_Author.DropTextColor(Colors.White)
    'edt_Author.DropTextSize(18)


   edt_Author.AddItem("artist 1", Null)
   edt_Author.AddItem("artist 2", Null)
   edt_Author.AddItem("artist 3", Null)
   edt_Author.AddItem("artist 4", Null)
   edt_Author.AddItem("artist 5", Null)
   edt_Author.AddItem("artist 6", Null)
   edt_Author.AddItem("artist 7", Null)
   p.AddView(edt_Author.AsView,0,25%y,60%x,150dip) ' these values don't work so the porition is set below
   
   edt_Author.setLeft(0)
   edt_Author.setTop(25%y)
   edt_Author.setWidth(60%x)
   edt_Author.setHeight(50dip)

   Dim edt_song As EditText
   edt_song.Initialize("")
   edt_song.Hint = "Song Name"
   edt_song.HintColor = Colors.Gray
   edt_song.Text =  "test"
   edt_song.ForceDoneButton = True
   edt_song.SingleLine = True
   p.AddView(edt_song,0,25%y+100dip,100%x,60dip)
   
   Dim ret As Int
   
   ret = nd.Show("Enter artist and song names","Resolve","Cancel","",Null)
   If (ret = DialogResponse.POSITIVE) Then
      Log("Choose to resolve: artist=" & edt_Author.Text & " song:" & edt_song.Text)
         Log("Artist text is: " & edt_Author.Text)
   Else
      Log("Choose to cancel")
   End If
End Sub

Sub edtAuthor_ItemClick(Position As Int, Value As String)
   Log("item click:" & Value)
End Sub
 

HotShoe

Well-Known Member
Licensed User
Longtime User
B4X:
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(a As activity)
   Dim nd As CustomDialog

Hmm, I've never used (or known about) a custom dialog, so I'll need to study this and see what can be done.

--- Jem
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Melemoud,

I have looked into this, but I have decided not to take any action. that's because it is only happening while using a custom modal dialog library. It is too specific to rip the thing apart to mess with.

Thanks,

--- Jem
 

melamoud

Active Member
Licensed User
Longtime User
No problems Im using a regular view right now

Thanks for adding set text feature so fast.
 

jfranz

Member
Licensed User
Longtime User
Almost a complete version

This is the closest and best example of dropdown support that is currently available on this site. Only thing is it's missing the following attributes.

1. Option to force selection of item in list.
2. Filter results as they type. Similiar to the SeachView by Erel.

I wish source code for library's like this were available so that more Views could be created by myself and others. I fight with lack of good quality views other than the generic one's Erel has included in the Designer. I don't have hours and hours to invest in searching through this forum when most of them answer very easy issues.

Thanks for this dropdown and I look forward to seeing more support built into this one.
 

HotShoe

Well-Known Member
Licensed User
Longtime User
Thanks for the kind words Jfranz. I have attached the source to the first post. It is a b4a class that gets compiled to a library, but it works fine as a normal class file as well.

I like your suggestions. The first is pretty simple, not sure about the second though. I'll play around with it.

Thanks,

--- Jem
 

jfranz

Member
Licensed User
Longtime User
Wow, what great support the users of B4A provide. I expected an answer within a week or so and didn't expect the source to this. I can't wait to get home and look over the code and play with it. Thank you very much for the time spent on this and hopefully I can offer some additional help or support in the future.
 

moster67

Expert
Licensed User
Longtime User
Hi Jem,

Many thanks for this control.

I have been playing with your code (using the zip-file with the source-code) and it works really well.

However, I noted that if I use your demo-code running ICS or Jelly Bean with an emulator, the click-event of the droplist only works the first time while on all successive clicks, the event is not triggering. This is not entirely true, eventually it will trigger but you can never tell when. Oddly enough this does not happen on my Nexus7-device! Needless to say, I have created more than one emulator or re-creating them and the result is always the same. Running an emulator with Gingerbread works fine.

Are you aware of this? Is there any workaround to get it working using the emulator?
 

Steve Miller

Active Member
Licensed User
Longtime User
Would you be able to update the control so that a value and text can be added to the combobox? Then the user can use getText to get the text displayed, or a new method getValue where the user can get the value of the item. Also, the user can use setText to set the selected item in the box by text string, or a new method setValue to set the selected item by value.

For instance, suppose I want to load a combobox with the states. I would load the following:

Value='AL', Text='Alabama'
Value='NY, Text='New York'
etc.

Then If I can set the default selected item by value ('AL', 'NY', etc) using setValue, or by text ('Alabama', "New York', etc.) using setText.
I can also get the selected item by value using getValue, or by text using getText.

Hopefully, this can be done. This is a feature I really need. Thanks!
 

HotShoe

Well-Known Member
Licensed User
Longtime User

HIya Moster, long time no type my friend. No, I rarely ever use an emulator for my stuff, but I will create one and see what it is doing. I'll post back when I know more.

Thanks,

--- Jem
 

HotShoe

Well-Known Member
Licensed User
Longtime User


So, you want it to act as a hash table? What would the dropdown display? would it be 2 columns, or just the index values? I'm not sure I fully understand what the dropdowns function would be in this arrangement.

Thanks,

--- Jem
 

Steve Miller

Active Member
Licensed User
Longtime User
So, you want it to act as a hash table? What would the dropdown display? would it be 2 columns, or just the index values? I'm not sure I fully understand what the dropdowns function would be in this arrangement.

Thanks,

--- Jem
For my purposes, I would like to display 'Alabama', 'New York', etc. in the dropdown portion. That's what the user would see. For instance, the user selected 'New York' from the dropdown. There could be two method calls.

getText = return the text of the selected item from the dropdown, in this case 'New York'.
getValue = return the value of the selected item from the dropdown, in this case 'NY'.
 

peacemaker

Expert
Licensed User
Longtime User
If the view is placed at the screen bottom - it cannot be ised, right ?
Would be good, if it is open above itself, if at bottom. As standard "big brother" OS comboboxes.
 

HotShoe

Well-Known Member
Licensed User
Longtime User
I thought it did. I'll look at it tonight and make any changes needed.

Thanks,

--- Jem
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…