比如在viewpager中点击音量键调节上一页下一页,return true就可以取消音量界面的显示
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (voiceRead.equals("open")) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
vp.setCurrentItem(vp.getCurrentItem()+1);
return true;
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
vp.setCurrentItem(vp.getCurrentItem()-1);
return true;
}
}
return super.onKeyDown(keyCode, event);
}
本文出自 “7530017” 博客,转载请与作者联系!