ITeye博客

Android PopUpWindow 软键盘

trinityblood · 2012-12-03 01:56 · android · 移动开发 · Markdown

点击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);

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。