zoukankan      html  css  js  c++  java
  • Android 自定义Popupwindow 注意事项,手机和平板的区别

    首先自定义ppw是要继承Popupwindow 的

    而要成功的显示出自定义的ppw就必须实现下面的三句代码

    // 必要的三要素下面,不然popWind显示不出来
    this.setContentView(mView);
    this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
    this.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);

    //上面的代码是必须设置的,不然ppw显示不出来。

    this.setFocusable(true);// 使popwind中获取不到焦点,默认是false,这里是为了使EditText没有焦点,从而不会弹出输入框

    this.setBackgroundDrawable(new BitmapDrawable());
    this.setOutsideTouchable(true); // 点击popwind以外的地方关闭popWind

    //这两句代码我要来解释一下

    (1)、setFocusable()这个方法如同上面的解释一样,但我要提醒的是:

        如果你自定义的ppw包含了ListView这个控件并设置了OnItemClickListener事件,

        因为我在项目开发中遇到这个问题所以提出来,这句代码在手机端的时候不管你设置了true还是false  ,ListView的OnItemClickListener事件都会触发,但在Android平板中设置了false是不会触发OnItemClickListener这个事件的,所以要提醒大家注意一下

    (2)、setOutsideTouchable()这个方法的说明就是点击ppw以外的地方关闭ppw,但如果你这么就设置为true的话,那么告诉你这是不起任何作用的,别问我为什么,因为我也不知道,如果想要起作用就必须还要设置这个setBackgroundDrawable(new BitmapDrawable());// 这样设置才能点击屏幕外dismiss窗口  ,这两句代码同时使用才能起到效果

  • 相关阅读:
    ajax 406 Not Acceptable
    HTTP Status 400
    HTTP Status 500
    ClassNotFoundException: javax.validation.ValidatorFactory
    mysql 外键引发的删除失败
    Cannot invoke Tomcat manager: socket write error
    记一次恐怖的 Integer 溢出
    又见 tomcat启动startup.bat一闪而过
    Cannot run Eclipse; JVM terminated. Exit code=13
    The type javax.swing.JComponent cannot be resolved. It is indirectly referenced from required .class files
  • 原文地址:https://www.cnblogs.com/woaixingxing/p/5581386.html
Copyright © 2011-2022 走看看