popwindow 加listview OnItemClickListener失效问题

  在初始化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获取焦点后其他事件失效问题
     
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值