Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Spinner content on opening

I've a Spinner and its content depends on actual location (GPS position). So the content should changes continually, but it's only visible to the user when he/she selects an item. Instead of having a thread who continually updates the Spinner content, or a button to force an update from the user, I'd like to obtain another behaviour. When the user touches the Spinner, before the Spinner opens, it should be updated. I'm already able to change programmatically the Spinner's content. What I need is an event that triggers when the user touch the closed Spinner, but before the opened Spinner is shown. I hope this question is clear enough. Thank you for you attention.

like image 664
Sebastian Ikaros Rizzo Avatar asked Feb 14 '13 10:02

Sebastian Ikaros Rizzo


1 Answers

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;
    }

});
like image 60
iTech Avatar answered Sep 22 '22 16:09

iTech