Last active
August 27, 2016 08:55
-
-
Save billmote/bde335f6274d606c67f2 to your computer and use it in GitHub Desktop.
A spinner that only updates when the user touches the screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A member variable | |
private boolean userIsInteracting; | |
/* | |
Beginning with API level 3 you can use onUserInteraction() on an Activity with a boolean to determine if the user is interacting with the device. | |
http://developer.android.com/reference/android/app/Activity.html#onUserInteraction() | |
*/ | |
@Override | |
public void onUserInteraction() { | |
super.onUserInteraction(); | |
userIsInteracting = true; | |
} | |
private void setupViews() { | |
mSpinnerView.setOnItemSelectedListener(new OnItemSelectedListener() { | |
@Override | |
public void onItemSelected(AdapterView<?> arg0, View view, int position, long arg3) { | |
spinnerAdapter.setmPreviousSelectedIndex(position); | |
if (userIsInteracting) { | |
updateGUI(); | |
} | |
} | |
@Override | |
public void onNothingSelected(AdapterView<?> arg0) { | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment