// 声明一个弹出框
popupWindow = new PopupWindow(layout, 250, layout_height);
popupWindow.setFocusable(true);
// popupWindow+listview,实现listview选中事件和pop点击隐藏的效果,必须加这行代码。 好jb邪恶
popupWindow.setBackgroundDrawable(getResources().getDrawable(
R.drawable.activity_propopbg));
// 为弹出框设定自定义的布局
popupWindow.setContentView(layout);
popupWindow.showAsDropDown(findViewById(R.id.doublelinear), -20, -10);
popupWindow.setOutsideTouchable(true);
popupWindow.setTouchable(true);
popupWindow.setTouchInterceptor(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
System.out.println("........aaaaaa");
/**** 如果点击了popupwindow的外部,popupwindow也会消失 ****/
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
popupWindow.dismiss();
return true;
}
return false;
}
});
PopupWindow+ListView 关于listview选中和pop外部点击隐藏
猜你喜欢
转载自wfkbyni.iteye.com/blog/1661206
今日推荐
周排行