第一种情况:
在使用Dialog.show();之前吧view添加进来:
Dialog.setView(((Activity) ctx).getLayoutInflater().inflate(R.layout.search_popwindow, null));
public void showDialog() {
this.setView(((Activity) ctx).getLayoutInflater().inflate(R.layout.search_popwindow, null));
LayoutInflater inflater = LayoutInflater.from(ctx);
View textEntryView = inflater.inflate(R.layout.search_popwindow, null);
this.show();
this.getWindow().setBackgroundDrawable(new ColorDrawable(0));
getWindow().setContentView(textEntryView);
WindowManager.LayoutParams lp=this.getWindow().getAttributes();
lp.width=LayoutParams.FILL_PARENT;
this.getWindow().setAttributes(lp);
this.setCanceledOnTouchOutside(true);
}
第二种情况:
软键盘被代码写死隐藏
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
当然当我们需要清除该状态时,可以在输入控件的Touch事件里面进行解除
EditText.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
return false;
}
});