Android PopUpWindow 软键盘

点击EditText的时候,同时显示PopUpWindow和软键盘

@Override
warnSearch.setOnTouchListener(this);
public boolean onTouch(View v, MotionEvent event) {
    // TODO Auto-generated method stub
    Log.d(TAG, "edit onTouch");
    if (event.getAction() == MotionEvent.ACTION_UP) {
    	searchViewShow();
    }
    return false;
}
public void searchViewShow(){
    popUpWindow = new PopupWindow(searchView, screenWidth, 60);
    // 使其获取焦点
    // popUpWindow.setFocusable(true);
    // 设置允许在外点击消失
    popUpWindow.setOutsideTouchable(true);
    // 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景
    popUpWindow.setBackgroundDrawable(new BitmapDrawable());
    // 显示在warnSearch的下面(warnSearch是一个EditText)
    popUpWindow.showAsDropDown(warnSearch, 0, 0);
}


实现这个效果的关键是:下面这句代码是一定不能有的,所以我注释掉le
popUpWindow.setFocusable(true);

猜你喜欢

转载自trinityblood.iteye.com/blog/1739911