I want to create something similar to a listpreference menu item with a single selectable option out of four options. The problem is that descriptions are necessary for each selectable option and they are rather long. Shortening descriptions further isn't an option.
The Android app I'm working on currently uses a custom method for displaying a menu item's summary field. The summary calls an int which points to a string reference stored in a different file that displays a string. I tried using %s as the summary to update the summary with my selected option but that literally returned "%s". I don't think the current method supports dynamically loading summaries.
My next idea is to create a submenu with four selectable choices (maybe checkboxes?) and only allow one to be chosen. I think this is essentially a listpreference menu item but allows more space for separated descriptions. Is there a preferred way to accomplish this? I'm trying to avoid re-writing the original custom method for displaying descriptions as it works well for the rest of the app's menu needs.
EDIT 1: An image will help explain what I want. See Android sample settings menu. I want to create a section similar to the "embedded frame buffer" section in a submenu except only one of the three options are selectable. This approach will allow me to have more room for separated, long descriptions. Perhaps I'm looking for radio buttons with no popup and one selectable choice? Is this a thing in Java?
Not sure if I understand the question correctly but instead of a list of checkboxes where only one checkbox is checkable use a RadioGroup with Radiobuttons. You can have multiple RadioButtons which you add to a RadioGroup and then only one RadioButton can be selected.
Related
I want to create Menu like this. Tap on any Item it will open Submenu with Items
I don't think there exists a library which will allow you to do this. (I may be wrong).
But according to me the best possible way to achieve this would be to use two tableViews placed next to each other and updating the the data for the second tableView on didSelectRow of the first tableView. You would have manage a few complexities but it is achievable.
If you only have 2 level of details in your menu, you could also use one tableView, show the 1st level elements in the section header, and create rows on section header click (using a button or tap) for the second level elements.
Edit:
My answer mentions some iOS naming conventions. Because it was originally asked for iOS with tag iOS and swift. I decided not change the original answer because the core concept of achieving this should be similar on both platforms.
Anyways, I think you can still do same stuff for android, just use list view where I mentioned tableView
What are the differences between ComboBox and ChoiceBox in JavaFX? I'm not entirely clear on that just from the Javadoc for both classes.
At the end of the day, I need a dropdown control that can be repopulated dynamically at runtime (I've got a database on the backend). For all cases in my application, I only need to select one item from the dropdown menus. The user also shouldn't be able to add an option to the dropdown menu from the screens they are visible on.
My understanding is that ComboBox allows the user to add items to the dropdown list and allows for selecting multiple items, but from the Javadoc it seems like it's possible to setup ComboBox in a way that meets my needs, so it seems like they're interchangeable to some extent. I guess ComboBox has a bit more overhead than I really need in this case, but is there anything else that only a ComboBox could do that would factor into this decision?
Edit
I guess I kind of answered my own question on the key differences, so is there something else I've not mentioned that differentiates the 2?
ComboBox supports a cellFactory which allows essentially an arbitrary UI for displaying the item in each cell. ChoiceBox does not have this functionality and will only display text in each cell (which you can configure using a converter).
See http://docs.oracle.com/javase/8/javafx/user-interface-tutorial/combo-box.htm#BABJCCIB listing 16.5 for an example of a custom cell factory in a combo box.
Well ChoiceBox is of the idea showing you optional choices, and ComboBox well shows you a list of items, ChoiceBox is like ComboBox but ComboBox is for a really lengthy list as you can specify the number of items to display like 10 or more or less, but ChoiceBox does not have the option it list all options and if its very long you wouldn't like the look.
in short ChoiceBox, for small set of list less than 10, for more ComboBox
That is from my perspective the difference, as for styling you can style all.
Combo Box
A combo box is a typical element of a user interface that enables users to choose one of several options. A combo box is helpful when the number of items to show exceeds some limit, because it can add scrolling to the drop down list, unlike a choice box. If the number of items does not exceed a certain limit, developers can decide whether a combo box or a choice box better suits their needs.
Choice Box
This chapter describes choice boxes, the UI controls that provide support for quickly selecting between a few options.
http://docs.oracle.com/javafx/2/ui_controls/jfxpub-ui_controls.htm
We can simply differentiate ComboBox and ChoiceBox by their functionalities.Just have a look on deffintion.
The JavaFX ComboBox control enables users to choose an option from a predefined list of choices, or type in another value if none of the predefined choices matches what the user want to select.
The JavaFX ChoiceBox control enables users to choose an option from a predefined list of choices only.
Apart from the mentioned differences:
ComboBox can show a prompt with setPromptText (ChoiceBox doesn't provide that method)
ComboBox can show more than 10 rows with setVisibleRowCount (ChoiceBox doesn't provide that method)
I've one seen on an application for iPhone an interesting idea which consists of showing a list of options when we click on an area for text edition. For example, imagine I have a field called "City" (EditText) which I am suposed to enter the name of the city. When clicking on the EditText, a list automatically shows up with a few city suggestions (e.g. defined by the programmer) which can be selected. If the user doesn't like the suggestions, he writes the city himself and this city can be saved for this list for future.
I want to programme this on my App for android. I need that, when clicking on the EditText for introducing the data, a list automatically shows up with some suggestions defined by me (Programmer). However, I don't know how this can be done. I've googled but maybe it's hard to find the correct keywords to find a similar topic.
The idea is that the user should use the names already written in the list in 90% of the time and just write himself the new ones when it's necessary. Something like a dropdown list but with possibility of writing new stuff instantly without specific option.
How can this be achieved?
You Need Something Like View in android Named as
AutoTextComplete
Examples How to use this :
help
Best of luck
You can consider focus changed listener for Edittext,
when focus is gained you can show a context menu to choose data from.
I am trying to implement a text box that, when the user types something, it asynchronously expands a drop-down menu that contains suggestions, much like how the Google search bar shows predictive search queries. In other words, combining an EditText with a Spinner in the sense that the user types something and it presents a list of selectable options right below it. Does such a class exist in the Android library?
You can follow this tutorial from android:
http://developer.android.com/resources/tutorials/views/hello-autocomplete.html
is an auto complete example on a EditText.
For those who are familiar with SwingX's AutoCompleteDecorator, I have a question regarding handling of JComboBox's Popup Visibility. I used AutoCompleteDecorate.decorate(JComboBox combobox) in my current project which I already mentioned in my previous posts, the problem I encountered is when ever the user type a keyword that doesn't match any of the combobox items, the popup remains visible. For the convenience of the users, I would like to hide combobox's popup if the keyword typed doesn't match any of combobox items.
If you want the autocompletion feature, but you don't want to have a popup in the way (especially, as you mention, when entered text doesn't match any item) you might like to try the opensource JIDE Common Layer. It has a very useful (I use it a lot myself) autocompletion feature that you can apply to JComboBoxes, JTextFields, etc..
You can see a Java Web Start overview of the components by clicking on the "RUN IT" link on the above page, or by clicking here. Navigate to
Demos->AutoCompletion Demo->AutoCompletion combo box and text field->AutoCompletion JTextField with a hidden data
to try it out. You can also see the source code by clicking on Browse Source Code.
You can enable/disable a strict flag in order to prevent/allow user to enter text not matched with items.
However, as far as I have tested, JIDE's combo boxes with autocompletion also have the "issue" that keep their popup open even if no match is found, but what I'm suggesting here is to try an autocompleting textfield which has no popup at all (they autocomplete in place, highlighting the part of the matched text that you didn't manually type-in).