简体   繁体   English

如果单击带有GWT中的活动和位置的浏览器的后退按钮,则将一次又一次地调用关键侦听器

[英]Key Listener called again and again if I click on Browser's back Button with Activity and Places in GWT

I am creating search page and I have use activity and places in GWT. 我正在创建搜索页面,并且已在GWT中使用活动和位置。 I have used Key Listener so when user press Enter it redirect user on result page. 我使用了Key Listener,因此当用户按Enter时,它将在结果页面上重定向用户。 Problem is that when user use browser back button and again press enter Key Listener call twice same if user again click back button next time it will call trice and so on. 问题是,当用户再次使用浏览器后退按钮并再次按Enter键时,如果两次再次单击后退按钮,它将调用trice,依此类推。 Is there any solution for this? 有什么解决办法吗?

You're probably adding your listener when activity starts but never remove it (eg when activity stops). 您可能在活动开始时添加了侦听器,但从不删除它(例如,活动停止时)。

The full solution depends how you code your activity (do you reuse activity instances? do you have a separate view with activity acting as a presenter/controller? if so, is the view a singleton, or at list lives longer than the activity and can be reused by another activity instance? etc.) 完整的解决方案取决于您对活动进行编码的方式(您是否重复使用活动实例?您是否有一个单独的视图,其中活动充当演示者/控制者?如果是这样的话,该视图是单身人士还是列表中的人比活动寿命更长并且可以被另一个活动实例重用?等)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM