// 声明一个弹出框
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
popupwindow + listview 多级展示
PopupWindow+ListView实现Android搜索框
在PopupWindow中嵌入ListView,ListView中的item可在顶部与底部之间跳跃.
使用PopupWindow + 2个ListView实现仿 美团/淘宝/百度糯米 多级分类菜单效果
PopupWindow + ListView + Singleselect
NULL 博文链接:https://hhulijin.iteye.com/blog/1495082
PopupWindow和ListView配合使用,包含PopupWindow的取消,Back键取消,ListView的点击事件。
PopupWindow ListView 单选的简单实现