思路:重写ListView的setOnTouchListener事件;
1 ListView.setOnTouchListener(new OnTouchListener(){ 2 3 @Override 4 public boolean onTouch(View arg0, MotionEvent arg1) { 5 // TODO Auto-generated method stub 6 hideMenu();//隐藏菜单 7 return false; 8 } 9 10 });
延申:
点击窗体空白地方隐藏菜单或软键盘思路一样:
1 @Override 2 public boolean onTouchEvent(MotionEvent event) { 3 // TODO Auto-generated method stub 4 hideMenu(); 5 return super.onTouchEvent(event); 6 7 }