Coder Social home page Coder Social logo

Comments (16)

lapDog avatar lapDog commented on June 2, 2024 1

image
这么解决也是可以的。。。(ง •_•)ง

from basepopup.

razerdp avatar razerdp commented on June 2, 2024

setBackPressEnable(false) ,不是true

from basepopup.

flyjiang2014 avatar flyjiang2014 commented on June 2, 2024

好像我的小米手机设定true 和 false 都没效果,但用模拟器有效果

from basepopup.

NikoSoftware avatar NikoSoftware commented on June 2, 2024

模拟器设置了,也没用

from basepopup.

razerdp avatar razerdp commented on June 2, 2024

@NikoSoftware

有没有具体的代码,或者其实您可以进行调试。。。

以及是否会是特定的api或系统版本导致的,如果您能帮忙排查,万分感谢-V-

from basepopup.

Mr-PolarBear avatar Mr-PolarBear commented on June 2, 2024

@razerdp 你好 setBackPressEnable(false) 无效
我在红米6.0 华为6.0 魅族5.1系统上测试不能拦截返回按钮

from basepopup.

razerdp avatar razerdp commented on June 2, 2024

@Mr-PolarBear
@NikoSoftware
@flyjiang2014

对于Android M以上暂时无法修复呢。。。残念(首页README已经补充)

https://github.com/razerdp/BasePopup/blob/master/%E5%85%B3%E4%BA%8EAndorid%20M%E4%BB%A5%E4%B8%8AsetBackPressEnable()%E5%A4%B1%E6%95%88%E7%9A%84%E9%97%AE%E9%A2%98%E7%9A%84%E5%88%86%E6%9E%90.md

from basepopup.

zl277287818 avatar zl277287818 commented on June 2, 2024

@OverRide
public boolean onBeforeDismiss() {
if (canBack) {
return true;
} else {
return false;
}
}

自己用一个变量去控制,完美解决

from basepopup.

razerdp avatar razerdp commented on June 2, 2024

@zl277287818

啊哈,也可以的(虽然不太完美)。。。我都忘了我写过这个回调了- -我现在就加到readme里面

from basepopup.

razerdp avatar razerdp commented on June 2, 2024

@zl277287818

不过这个方法有个问题,因为beforeDismiss会很粗暴的影响dismiss()流程,如果我只需要返回键不dismiss而点其他地方可以dismiss,这个方法就可能需要一个方法来提前把canBack改变以适应不同的需要,所以并不是非常完美哦

from basepopup.

zl277287818 avatar zl277287818 commented on June 2, 2024

是的,不是很完美,现在finish页面的时候,我就是先set成true再dismiss... 不然泄露。不过可以临时解决一下项目需求。

from basepopup.

razerdp avatar razerdp commented on June 2, 2024

@lapDog 是的,在activity下捕捉是可以的哈哈,只是如果想从popu内部捕捉,目前来说除非能拿到popup内部的那个framelayout,否则似乎没啥办法呢

from basepopup.

JadynChan avatar JadynChan commented on June 2, 2024

同时加多一个条件 mPopupWindow.setFocusable(true);就可以按返回键关闭了

from basepopup.

zhupengxiang avatar zhupengxiang commented on June 2, 2024

这个onBrforeDismiss怎么解决的返回键问题 没怎么看懂

from basepopup.

razerdp avatar razerdp commented on June 2, 2024

@zhupengxiang 在activity给beforeDismiss回调,在activity捕捉keyevent,或者backpress从而决定popupwindow是否返回关闭

from basepopup.

razerdp avatar razerdp commented on June 2, 2024

@NikoSoftware
@flyjiang2014
@Mr-PolarBear
@zl277287818
@lapDog
@JadynChan
@zhupengxiang

感谢你们的讨论和idea~在1.8.9里面我用了一种新的思路去解决这个问题,建议大家升级到1.8.9

具体解决方式:1.8.9 解决方案

如果大家有更完美的解决方案,欢迎继续探讨哦~

本issue不关闭。

from basepopup.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.