aliehuhu
V2EX  ›  Android

点击返回键怎么让 popupwindow 消失?

  •  
  •   aliehuhu · Jun 18, 2018 · 13892 views
    This topic created in 2935 days ago, the information mentioned may be changed or developed.
    代码如图:


    现在问题是第一按返回键,软键盘关闭;
    第二次按返回键,popupwindow 才关闭,setOnKeyListener 那段代码没生效。
    5 replies    2018-06-18 10:49:25 +08:00
    sundae91
        1
    sundae91  
       Jun 18, 2018   ❤️ 1
    复写 onBackPressed()方法
    yanhejihe
        2
    yanhejihe  
       Jun 18, 2018   ❤️ 1
    这个我处理过,是 popupwindow 的一个大坑
    yanhejihe
        3
    yanhejihe  
       Jun 18, 2018   ❤️ 1
    推荐还没入坑的换 bottom sheet 或 dialog fragment
    yanhejihe
        4
    yanhejihe  
       Jun 18, 2018
    没注意看代码,和我的不大一样。你这个应该是键盘关闭事件监听的问题。
    xingda920813
        5
    xingda920813  
       Jun 18, 2018 via Android
    setOnPreImeListener
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1663 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 16:19 · PVG 00:19 · LAX 09:19 · JFK 12:19
    ♥ Do have faith in what you're doing.