In My Layout there is a EditText for search and there is a list below the EditText.Now I'm inflating this layout in a PopupWindow . Now My problem is
1)If I set the PopupWindow focusable true , then all the places other than the PopupWindow Layout becomes non clickable.So I can not dismiss the window by clicking outside or by clicking on the back button of the device
2)If I set the PopupWindow focusable false , then the Popupwindow open and close is perfect but soft keyboard is not becoming visible on tap of the EditText
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// Inflate the view from a predefined XML layout View layout = inflater.inflate(R.layout.popup_layout, null);
mPopUpWindow= new PopupWindow(layout,0, mScreenHeight - 100, false);
mPopUpWindow.setBackgroundDrawable(null);
mPopUpWindow.setOutsideTouchable(true);
mPopUpWindow.setTouchInterceptor(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
mPopUpWindow.dismiss();
}
return false;
}
});
final InputMethodManager inputMgr = (InputMethodManager) MainApplication.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
inputMgr.showSoftInput(mEditText, InputMethodManager.SHOW_IMPLICIT);
mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
inputMgr.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
return true;
}
return false;
}
});