boolean mFirstDown; @Override public boolean dispatchKeyEvent(KeyEvent event) { if(event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { mFirstDown = true; } if(event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) { if(parent != null) { DialtactsActivity da = (DialtactsActivity)parent; if(da.mTabHost.getCurrentTab() == da.TAB_INDEX_CONTACTS && mFirstDown){ mFirstDown = false; da.mTabHost.setCurrentTab(da.TAB_INDEX_CALL_LOG); }else{ da.mTabHost.setCurrentTab(da.TAB_INDEX_CONTACTS); } return true; } } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT) { if(parent != null) { DialtactsActivity da = (DialtactsActivity)parent; if(da.mTabHost.getCurrentTab() == da.TAB_INDEX_CONTACTS && mFirstDown){ mFirstDown = false; da.mTabHost.setCurrentTab(da.TAB_INDEX_FAVORITES); } return true; } } return super.dispatchKeyEvent(event); }
时间: 2024-12-12 20:23:24