// declare view, width, height ...
PopupWindow popupWindow = new PopupWindow();
popupWindow.setContentView(view);
popupWindow.setWidth(width);
popupWindow.setHeight(height);

上面这段代码在Android 4.0 真机(ZTE V889D)调试没有问题,但是在Android 2.2模拟器上使用,就会报运行时异常和空指针异常,改用下面的代码没有问题:

// declare view, width, height ...
PopupWindow popupWindow = new PopupWindow(view, width, height);

所以,为了兼容性,不要使用PopupWindow默认构造方法。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
猜你喜欢
  • 2021-06-18
  • 2021-07-10
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案