zoukankan      html  css  js  c++  java
  • Android中ListView放入PopupWindow产生问题解决

    今天在做项目时候发现将ListView放入PopupWindow产生问题,ListView放入PopupWindow后
    对PopupWindow设置了setFocusable(true)这时候其他的控件全部没有响应了!
    我的解决方案是,ListView放入PopupWindow后对你对PopupWindow设置了setFocusable(true);
    让PopupWindow获得了焦点这时候你点击其它控件是无法响应的。
    这时候你可以通过pw(PopupWindow对象).getContextView()拿到他的父视图。

    然后通过给父视图注册事件 让pw失去焦点 我是这样做的:

        pw.getContentView().setOnTouchListener(new OnTouchListener(){  
          
                                                @Override  
                                                public boolean onTouch(View v, MotionEvent event) {  
                                                        // TODO Auto-generated method stub  
                                                        pw.setFocusable(false);//失去焦点  
                                                        pw.dismiss();//消除pw  
                                                        return true;  
                                                }  
                                                  
                                        });  
    

      

  • 相关阅读:
    单例设计模式
    使用JfreeChart生成统计图
    session的生命周期
    json
    struts2 ognl标签使用
    集合小结
    多线程
    内部类和匿名内部类
    模版方法设计模式
    mac中yeoman构建你的项目
  • 原文地址:https://www.cnblogs.com/jsonfan/p/5329291.html
Copyright © 2011-2022 走看看