Prevent Spiner.setOnItemSelectedListener to change selection - android

I am developing a VIP future in my application. When user clicks on a vip option from spinner I want to show him a popup rather than changing spinner selection.
How would you solve it?
Note that I don't want to disable setOnItemSelectedListener, just for vip options.

Save your current selected position/item in a variable.
In your OnItemSelectedListener:
a. if a VIP item is selected show your popup and reset your selection to saved position.
b. else proceed normally.

Related

Android ListPopupWindow Detecting Click outside of list

I'm using ListPopupWindow which I find very suitable for the purpose with one exception. I want to be able to detect when the user does other than select an item from the list or presses the back button. Currently what is happening is that when an item is clicked outside of the ListPopupWindow list I cannot determine what was clicked and the ListPopupWindow is dismissed. Ideally what I would prefer is for the user to only be able to select an item from the list or press the back button, however I cannot achieve that. I've searched for an answer and experimented for hours but I cannot achieve what is required. As far as I can determine, setting modal to either true or false appears to make no difference. I can obviously detect what is selected from the list, however whether the user presses the back button or clicks outside of the list appear to both dismiss the ListPopupWindow and I cannot determine the action that caused it other than an item was not selected. How can I either detect or prevent other than the user selecting an item from the list or pressing the back button?
As far as I can determine, this can be solved using
android.support.v7.widget.ListPopupWindow;
and
setForceIgnoreOutsideTouch(true)

Android Suggestion TextField

I'm trying to design a user form and I was wondering if it's possible to create a TextField that when the user clicks on it a dropdown list appears with suggestions ( based on previous values entered by the user )
and the user has the choice to either pick on of the suggestions or writes his own in the text field .
Thank you
You can Use AutoCompleteTextView
An editable text view that shows completion suggestions automatically while the user is typing. The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with.
Check Demo android_auto_complete

Show Prompt in Spinner when activity is resumed

I have a spinner in my activity which is loaded with the database values. First time when the activity is loaded the spinner is selected to show the prompt text. When i go to the next activity and press back button then the spinner is selected to show the first item. But i need to show the prompt text when the activity is resumed.
How to achieve that? I need your help.
Plz post your first activities info (code and xml). This would help us give an accurate answer.
However, if you programmatically set your spinner with :
mSpinner.setSelection(0); // or whatever index you want to revert to
BEFORE you start up your 2nd activity. You should be good to go.
What you have done, to make spinner show the prompt text, do it in:
onResume method (Override it).
Also, if the thing that causes the spinner to show prompt text, is something that is not set yet, and you set it later(somewhere in onCreate, so it wont re-show it again in future),
you can override also onPause, to unset it.
Activity lifecycle is the key!

Is it possible to detect when an item in the contextmenu is not selected?

Could I detect if the menu pops up and someone clicks off the screen (closing it without selecting a value)?
Currently I have a checkbox that when clicked opens a contextmenu with choices. When I click off of it without selecting a value I would like the checkbox to disappear.
Thanks.
Should be, have you looked into the Reference Guide for onContextMenuClosed()?

How to grey out spinner in Android?

I use two Spinner in my App. One of them is initially disabled because I need the user to select something in the first spinner to load the content of the second one.
I would like to change the design of the second spinner to show the user that the spinner is not active, eg. grey the spinner out. How can I achieve this?
If this is not possible how would you change this dialog to make it clear to the user that she has to select something in the first spinner?
The Spinner doesn't gray out when disabled, it's a bug that we fixed in FroYo (next version of Android.)
Further to setting as disabled, I don't know any other way to grey out.
Hide the second spinner until the first has no selection.
Or until it's in disabled state, the first visible option should show text related to the required selection eg: Select a Continent first

Categories

Resources