Changing Spinner Content on Opening

I have a Spinner, and its contents depend on the actual location (GPS position). Therefore, the content should constantly change, but it is available only to the user when he selects an item. Instead of having a thread that constantly updates the contents of the Spinner or a button for forcing updates from the user, I would like to get a different behavior. When a user touches Spinner, before Spinner opens, it must be updated. I am already able to programmatically change the contents of Spinner. I need an event that fires when a user touches a closed Spinner, but until the open Spinner is shown. Hope this question is clear enough. Thank you for your attention.

+7
source share
1 answer

You can use onTouchListener

 spinner.setOnTouchListener(new OnTouchListener(){ @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN){ // Load your spinner here } return false; } }); 
+12
source

All Articles