Skip to content

Instantly share code, notes, and snippets.

@billmote
Last active August 27, 2016 08:55
Show Gist options
  • Save billmote/bde335f6274d606c67f2 to your computer and use it in GitHub Desktop.
Save billmote/bde335f6274d606c67f2 to your computer and use it in GitHub Desktop.
A spinner that only updates when the user touches the screen
// 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