Android Spinner Narrow by Keyboard - android

How can one narrow items in a spinner by keyboard input?
I am looking for the functionality seen in HTML select on Android. Basically, I have a spinner with multiple items (hundreds in my case) and I want to be able to narrow the spinner to items relevant to keyboard input. So, if I press "71", I will get items starting with 71....

You need to implement a filter on the adapter for your Spinner. If you aren't using a custom adapter, you will most likely need to create one.

Related

Why can OnItemClickListener not work with a Spinner?

I want to know if there is a specific reason why you cannot use OnItemClickListener with a spinner in Android? Looking through older posts ( setOnItemClickListener Not Works with Spinner and I have an error: setOnItemClickListener cannot be used with a spinner, what is wrong?) it seems as though people don't even bother with OnItemClickListener and rather go straight for OnItemSelectedListener. Why does Eclipse give OnItemClickListener as an option for a spinner if it can never work?
Some context- I'm not really too bothered by which method I use. As soon as the user selects an item from the spinner, I want to make a second spinner visible and populate it from the database based on the option selected in the first spinner. Now when I use OnItemSelectedListener, the second spinner is immediately set to visible. Is there a workaround for this?
Why does Eclipse give OnItemClickListener as an option for a spinner if it can never work?
Because everything extending AdapterView has setOnItemClickListener(). Just because some subclasses ignore it does not mean that the setter magically disappears.
Is there a workaround for this?
There is no workaround, because there is no problem, because it is doing exactly what you say you want to have happen ("I want to make a second spinner visible and populate it from the database based on the option selected in the first spinner"). A Spinner always has a selection if there is data to select from. Hence, your second Spinner should always be visible, since it is "based on the option selected in the first spinner", and there will always be an "option selected in the first spinner".
It sounds like what you really want is to only have the second Spinner visible for specific selections in the first Spinner, where you set up the first Spinner where there is some selection that, in business terms if not technical terms, means "no selection". You are welcome to do this, but then you will have to implement the logic to handle this, only showing the second Spinner when an appropriate value is selected in the first Spinner.

customize a spinner to drop down a textview and reduce the size of two other spinners with the same customized dropdown

So What My application does is query a Database, I finally have the query all worked out and I got it to display to a Textview. The problem is I want the user to be able to see the result of 3 separate but similar queries, all in the same Activity, in Textviews.
I have almost no knowledge of how to customize layout items in android and I really wanted to Have a layout with nothing but 3 spinners and whenever you click on one (or when you arrive at the Activity) to have one dropdown of a Spinner (Which has a textview) that takes up most of the screen but leaves enough room for the two other spinners to be clearly viewed and clicked but not displaying their textviews.
Then when one of the other Spinners are clicked, It would reduce the size of the spinner that was open (with textview) to just the spinner and open the dropdown (with textview) of the spinner that was just clicked.
I don't even know if this is possible and if it is where would I start?

Extended list view: Show text input inside once clicked

I am working on a UI where I have a list view. Each row has 2 information. One is Product name and the other is product ID stacked one over other. So each row has 2 lines of data.
What i want to do with this:
Once a user clicks on each row, it will further expand and show one input and one spinner. So it is basically for putting in Quantity and unit of measure.
Please let me know if this is achievable and if I can refer to some example.
What I need is more like
Taskos To Do List | Task List
https://play.google.com/store/apps/details?id=com.taskos&hl=en
All i need is that the category will not be expandable. Only the items will be expandable. All i need is an example of such app and then I can take it forward.
I think it could be done... you would need to put the extra widgets in your row layout, populate them and hide them upon list creation, then in your onListItemCLick you could unhide them.
Note I have no idea if this would work, but it seems reasonable that it might and it's what I would try and do to achieve the goal.
listView cannot be expanded. however you can use an expandablelistView
But the kind of functionality you want cannot be done this way(I guess.).
You can use
registerForContextMenu("your list View");
to register your list view
onCreateContextMenu
for the kind of action you want to be performed in your case its dialog with EditText and Spinner to have input from user

Multiple Selection Spinner

I have a spinner that acts like a filter for searching among several categories. But the problem is that the spinner allows only one category to select from. Is there a way to obtain a multiple selection behavior for the spinner, or what other alternatives exists?
S spinner is designed to show one item at a time. You might get away by making a spinner of checkboxes, but it will be probably an awful user experience.
I would suggest you a ListView instead and CHOICE_MODE_MULTIPLE. You can add a listview to a dialog as shown in this answer: is it possible to create listview inside dialog?
Android provides Spinner widget which has functionality similar to drop-down list. But Spinner accepts single selection. so we select only one item at a time.so We can achieve multi-select feature using a custom Pop-up Window with a multi-select list.
Pop-up window is similar to Dialogs except that a pop-up window can be positioned.
When the drop-down button is clicked a list will be displayed(as drop-down), then you can select multiple values. The selected values will be displayed in a Text box above the list.
for reference you can prefer this link:
http://asnehal.wordpress.com/2012/04/03/multi-select-drop-down-list-in-android/

Is it possible to use an expandablelistview as a dropdownview for a spinner?

I have a 2d array of strings. I would like to use a spinner to allow users to select values from the 2nd lvl of the array but I would like to display the selection options in a expandablelistview using the values of the 1st lvl of the array as category headers.
Is this possible, can someone point me in the right direction of how this should be implemented ?
You cannot directly use an ExpandableListView for the Spinner popup, any more than you can directly use a ListView for the Spinner popup. It is what it is, and that is defined by the Spinner class.
Options include:
Subclassing Spinner and overriding whatever drives the popup dialog
Copying Spinner into your project and replacing whatever drives the popup dialog (if overriding will not work due to method visibility, etc.)
Don't use a Spinner, and instead use a Button plus an AlertDialog containing an ExpandableListView, or something like that
In principle, you could override getDropDownView() in your SpinnerAdapter (e.g., ArrayAdapter). However, there is no concept of the drop-down view being disabled, and I assume you would want your category headers to be non-selectable. If, however, selecting a category is acceptable, this approach would be simplest.

Categories

Resources