When we touch a spinner, a popup list appear which shows the options to choose from.
But suppose there is a scenario where there are two spinners, one for selecting state and second for selecting school from that state .At start there is no school in the school spinner. When we select a state from state spinner , the schools for this state is loaded from the server and is shown in the school spinner.
The problem arises when user touches empty school spinner and we want to show a message dialog “Select state first”. After clicking ok button of the dialog to dissmiss it we see the popup list of school spinner behind the dialog.
To solve this prolem use the following code which catches the touch event and shows the dialog without the spinner popup list when the school list is empty else it shows the school list.