popupWindow 的监听问题
void show()
{
LayoutInflater layoutInflater=getLayoutInflater();
View view =layoutInflater.inflate(R.layout.main,null);
GridView gridview=(GridView)view.findViewById(R.id.grid);
gridview.setAdapter(new Adapter(this));
popupWindow=new PopupWindow(view, WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.WRAP_CONTENT);
popupWindow.setFocusable(true);
popupWindow.setTouchable(true);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
ClosePop();
}
});
// 实例化一个ColorDrawable颜色为半透明
//ColorDrawable dw = new ColorDrawable(0xb0000000);
ColorDrawable dw=new ColorDrawable(0xffffffff);
popupWindow.setBackgroundDrawable(dw);
// 设置popWindow的显示和消失动画
popupWindow.setAnimationStyle(R.style.mypopwindow_anim_style);
// 在底部显示
popupWindow.showAtLocation( ScrollingActivity.this.findViewById(R.id.od),
Gravity.BOTTOM, 0, 0);
WindowManager.LayoutParams layoutParams=this.getWindow().getAttributes();
layoutParams.alpha=0.5f;
this.getWindow().setAttributes(layoutParams);
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
System.out.println("123456");
ClosePop();
return false;
}
});
}