List of usage examples for android.widget SeekBar onKeyDown
@Override public boolean onKeyDown(int keyCode, KeyEvent event)
From source file:com.android.settings.SeekBarPreference.java
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() != KeyEvent.ACTION_DOWN) { return false; }// www .ja v a 2 s. c o m SeekBar seekBar = (SeekBar) v.findViewById(com.android.internal.R.id.seekbar); if (seekBar == null) { return false; } return seekBar.onKeyDown(keyCode, event); }
From source file:net.xpece.android.support.preference.SeekBarPreference.java
/** * Listener reacting to the user pressing DPAD left/right keys if {@code * adjustable} attribute is set to true; it transfers the key presses to the SeekBar * to be handled accordingly.//from w ww .j av a2 s . c o m */ private View.OnKeyListener buildSeekBarKeyListener(final SeekBar seekBar) { return new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() != KeyEvent.ACTION_DOWN) { return false; } if (!mAdjustable && (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT)) { // Right or left keys are pressed when in non-adjustable mode; Skip the keys. return false; } // We don't want to propagate the click keys down to the seekbar view since it will // create the ripple effect for the thumb. if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) { return false; } if (seekBar == null) { Log.e(TAG, "SeekBar view is null and hence cannot be adjusted."); return false; } return seekBar.onKeyDown(keyCode, event); } }; }