V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
aliehuhu
V2EX  ›  Android

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

  •  
  •   aliehuhu · 2018-06-18 10:21:24 +08:00 · 4774 次点击
    这是一个创建于 2110 天前的主题,其中的信息可能已经有所发展或是发生改变。
    代码如图:


    现在问题是第一按返回键,软键盘关闭;
    第二次按返回键,popupwindow 才关闭,setOnKeyListener 那段代码没生效。
    5 条回复    2018-06-18 10:49:25 +08:00
    sundae91
        1
    sundae91  
       2018-06-18 10:26:58 +08:00   ❤️ 1
    复写 onBackPressed()方法
    yanhejihe
        2
    yanhejihe  
       2018-06-18 10:35:37 +08:00   ❤️ 1
    这个我处理过,是 popupwindow 的一个大坑
    yanhejihe
        3
    yanhejihe  
       2018-06-18 10:36:22 +08:00   ❤️ 1
    推荐还没入坑的换 bottom sheet 或 dialog fragment
    yanhejihe
        4
    yanhejihe  
       2018-06-18 10:39:16 +08:00
    没注意看代码,和我的不大一样。你这个应该是键盘关闭事件监听的问题。
    xingda920813
        5
    xingda920813  
       2018-06-18 10:49:25 +08:00 via Android
    setOnPreImeListener
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   951 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 19ms · UTC 21:09 · PVG 05:09 · LAX 14:09 · JFK 17:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.