在初始化popwindow的方法里加上
mPopupWindowlist .setFocusable( true);
private void initPopuptWindow()
{
// LayoutInflater layoutInflater = LayoutInflater.from(this);
// View popupWindow = layoutInflater.inflate(R.layout.livelist,
null);
// RadioGroup radioGroup = (RadioGroup)
// popupWindow.findViewById(R.id.radioGroup);
// radioGroup.setOnCheckedChangeListener(this);
// 创建一个PopupWindow
// 参数1:contentView 指定PopupWindow的内容
// 参数2:width 指定PopupWindow的width
// 参数3:height 指定PopupWindow的height
mPopupWindowlist = new PopupWindow(livelist_linearlayout ,
170, 500);
mPopupWindowlist .setOutsideTouchable( true);
mPopupWindowlist .setAnimationStyle(android.R.style. Animation_Dialog);
mPopupWindowlist .update();
mPopupWindowlist .setTouchable( true);
mPopupWindowlist .setFocusable( true);
// 获取屏幕和PopupWindow的width和height
mScreenWidth =
getWindowManager().getDefaultDisplay().getWidth ();
mScreenWidth =
getWindowManager().getDefaultDisplay().getHeight ();
mPopupWindowWidth = mPopupWindowlist .getWidth();
mPopupWindowHeight = mPopupWindowlist .getHeight();
Log. i( "clw", "实例化popwindow" );
}
在点击事件里加上 mPopupWindowlist .setOutsideTouchable( true);(如果不加的话,那么其他的事件就会失去响应)
public void onClick (View
v)
{
switch (v.getId())
{
case R.id.videoView1 :
if (!mPopupWindowlist .isShowing())
{
// 设置离开焦点
mPopupWindowlist .setOutsideTouchable( true);
mPopupWindowlist .setBackgroundDrawable( newPaintDrawable());
mPopupWindowlist .showAtLocation(v,
Gravity.NO_GRAVITY , location [0]
- mPopupWindowlist .getWidth(), location [1]);
adapter.notifyDataSetChanged();
Log. i( "clw", "%%%%" );
}
else
{
mPopupWindowlist .dismiss();
}
break ;
default :
break ;
}
}
这样才可以解决popwindow里面listview OnItemClickListener失效问题和popwindow获取焦点后其他事件失效问题