Disable spinner from moving to last selected item on dropdown - android

I have a spinner where I am adding hint at the bottom(not adding to top as getSelectedItemPosition will consider the hint as well) using arrayadapter hiding it from showing on dropdown options. The problem I am facing is, if I make the hint to show for the first time by using setSelection, then drop will directly go to bottom of the list(though hint won't show). Is there way that the dropdown will always show the top item on dropdown list irrespective of what item I select previously?

Related

How to programmaticaly scroll Spinner dropdown menu to make first item visible

Is there a way to scroll spinner's dropdown list to top so first item is visible regardless which item is currently selected?
Obviously I need only to make vistible the item in the list without any selection.
ListView has smoothScrollToPosition() method to display a specific item in the list but spinner seems not to have a similar behavior.

How to prevent from closing (dismiss) spinner in dropdown mode after item's selection

I want to make custom spinner in which user can select one of the items on dropdown list (like in normal spinner) but I want to prevent from closing (collapsing/dismiss) dropdown list after item selection. Or closing dropdown when user tap two times on item instead of single tap. Is anyone here knows how to achive such behavior using spinner?
Set itemSelectedListener on your spinner and onItemSelected() run this code
spinner.setClickable(false);

Customize dropdown (Picker) list in xamarin.forms

I am working on xamarin.forms. I am creating an app for android. In app I have a dropdown list. I am using Picker for it. I customized it to look like dropdown. Now I need to make the first Index item to nonselactable. Means user can not select the first item. If user click on it nothing should happen. But currently when user click on the first index dropdown gets collapsed.
One more thing that I have to add in dropdown is a Cross button at index 1. Means at index 1, on left side there will be Cross button and at center there will be text like Select item. And this whole row should not be selctable. If user click at cross button dropdown should collapsed.
Anyone have idea how I can do this?
You can use listview for dropdown and control its visibility as per need.I faced similar situation where I customized list view to enact dropdown.There is another thing I want to know about Picker.Does your picker accepts or adds string only or you could customize it to accept views or controls?

Advanced AutoCompleteTextView. Many-to-one map

I want the autocomplete view to display multiple items for the same text item.
ie. with an input data, {{a,b,c,d}, {e,f,g,h}} the user could search and start typing in b, but only 1 item from a,b,c,d would be displayed in the autocomplete section.
How would I go about this?
Thanks
I found I could solve this problem by adding all the elements to the autocompletetextview like normal
However, for the items that had "aliases" I put them in as 1 item, separated by a separator character and a space. The space allowed the item to be selected using the normal functionality. Then I used a custom view for each of the items which identified which 'part' of the string was being entered and displayed that part in the dropdown item.
For my solution, I then hide the autocompletetextview, but you could also just call setText to overwrite the default behavior.

Android Spinner with no selected text - arrow only

I would like to create a spinner which only displays the drop-down arrow and not the selected value and is only the width of the arrow. You can see various examples of this in Android itself e.g. Settings->Display->Brightness (Edit: a commenter has pointed out that this is a DialogPreference, but I would like a similar effect using a spinner).
I have attached to the setOnItemSelectedListener event and set the selected text to null, but this does not decrease the width of the spinner and you can can briefly see the selected text flicker before it is set to null.
How can I do this with the spinner? Is the spinner the correct control to be using in the first place?
Thanks.

Categories

Resources