how can i set a error to the user as the spinner is mandatory and an item to be selected? : i want to get a error message in spinner, while clicking a button stating the user to "select a city".Can anyone please help me with the mainactivity.java code

 <Spinner
            android:id="@+id/spinner1"  android:layout_width="319dp" 
 android:layout_height="52dp"  android:layout_marginTop="11dp" android:entries="@array/state_arrays"/>