| java.lang.Object | ||
| ↳ | com.neomades.ui.View | |
| ↳ | com.neomades.ui.ComboBox | |
A ComboBox represents a list of choices into screen in order to
intercept events (touch and keys) to set a selected value from a list of
choices.
ItemSelectedListener comboBoxListener = new ItemSelectedListener() {
public void onItemSelected(int index, String item) {
// do some stuff
}
}
ComboBox myComboBox = new ComboBox();
// add items here with ComboBox.addItem() methods
myComboBox.setItemSelectedListener(comboBoxListener);
By default, the following properties are applied to a new ComboBox:
MATCH_PARENT.MATCH_CONTENT.HCENTER|VCENTER.| XML Attributes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Attribute Name | Related Method | Description | |||||||||
| font | setFont(Font) | Font resource id: Res.font.FONT_XXXX | |||||||||
| textColor | setTextColor(Color) | #AARRGGBB or a color | |||||||||
| textSize | setTextSize(int) | a size in dp | |||||||||
|
[Expand]
Inherited XML Attributes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.neomades.ui.View
| |||||||||||
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.neomades.ui.Alignment
| |||||||||||
From interface
com.neomades.ui.StretchMode
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
ComboBox()
Constructs a combo box with no elements
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| void |
addItem(String item)
Adds an item to the ComboBox
| ||||||||||
| void |
addItem(int resId)
Adds an item to the ComboBox.
| ||||||||||
| String |
getItem(int index)
Gets the item at the given position.
| ||||||||||
| int |
getSelectedIndex()
Returns the selected index
| ||||||||||
| String |
getSelectedItem()
Returns the selected item.
| ||||||||||
| void |
insertItem(int resId, int index)
Inserts an item at the given position
| ||||||||||
| void |
insertItem(String item, int index)
Inserts an item at the given position
| ||||||||||
| static void |
openChooser(View origin, String[] items, String selectedItem, ItemSelectedListener listener)
Opens a dialog chooser used to select one item from a range of many items.
| ||||||||||
| void |
removeAllItems()
Clears all the items of the combo box
| ||||||||||
| void |
removeItem(int index)
Removes an item from the combo box
| ||||||||||
| void |
setFont(Font font)
Set the font of the selected item.
| ||||||||||
| void |
setItemSelectedListener(ItemSelectedListener listener)
Sets the listener on this combo box, to listen when the selection changes
| ||||||||||
| void |
setSelectedIndex(int index)
Sets the selected index of the combo box to the index given in parameter
| ||||||||||
| void |
setSelectedItem(String item)
Sets the selected index of the combo box to the index given in parameter.
| ||||||||||
| void |
setTextColor(Color textColor)
Sets the button text color.
| ||||||||||
| void |
setTextSize(int sizeInDp)
Sets the text size to a given value (in dp).
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.neomades.ui.View
| |||||||||||
From class
java.lang.Object
| |||||||||||
Constructs a combo box with no elements
Adds an item to the ComboBox
| item | the string to add to the combo box |
|---|
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|
Adds an item to the ComboBox.
| resId | the string id assigned added to this combo box |
|---|
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|
Gets the item at the given position. If none is found, return null
| index | the index of the item to find |
|---|
Returns the selected index
Inserts an item at the given position
| resId | the string id assigned added to this combo box |
|---|---|
| index | the index where to insert |
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|
Inserts an item at the given position
| item | the string to insert |
|---|---|
| index | the index where to insert |
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|
Opens a dialog chooser used to select one item from a range of many items.
| origin | the view from where to show the dialog (usefull for iOS) |
|---|---|
| items | list of items |
| selectedItem | the original selected item |
| listener | callback to listen the new selection (could be null) |
| NullPointerException | if origin is null in iOS platforms |
|---|---|
| IllegalArgumentException | if items is null or empty, if
selectedItem is null.
|
Clears all the items of the combo box
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|
Removes an item from the combo box
| index | the index where to remove the item |
|---|
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|
Set the font of the selected item. This method does not change the font of the items in the opened chooser.
| font | the new font to set |
|---|
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|---|
| NullPointerException | if the font parameter is null |
Sets the listener on this combo box, to listen when the selection changes
| listener | the listener |
|---|
Sets the selected index of the combo box to the index given in parameter
| index | the index to select |
|---|
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|
Sets the selected index of the combo box to the index given in parameter. The item selected will be the first in the combo box that is equal to the String given in parameter.
| item | the item to select |
|---|
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|
Sets the button text color.
| textColor | new color for the text |
|---|
| CrossThreadException | if the method is called from outside the UI-Thread |
|---|---|
| NullPointerException | if the parameter is null |
Sets the text size to a given value (in dp).
| sizeInDp | size to set to the text |
|---|