ITeye博客

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

wfkbyni · 2012-08-24 11:37 · android · 移动开发 · Markdown

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。