`
wfkbyni
  • 浏览: 84941 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

PopupWindow+ListView 关于listview选中和pop外部点击隐藏

 
阅读更多
// 声明一个弹出框
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;
}
});

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics