安卓:快速按钮presses导致意向的多个实例 [英] Android: Fast button presses results in multiple instances of intent

查看:166
本文介绍了安卓:快速按钮presses导致意向的多个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我遇到了一个错误,如果用户快速地点击一个按钮,用意是将按钮连接到会火过多次,导致堆栈意图将需要回去再通过跟踪的。我怎样才能避免这种情况或解决这个问题?

谢谢 〜氏/ P>

这是onClickListener内。我在这里设置的布尔值,然后我取消它的过程结束。

 如果(!isDating)
        {
            intent.setClass(背景下,EventDate.class);
            isDating = TRUE;
            ((TabGroupActivity)
            上下文).startChildActivity(EVENTDATE,意图);
        }
 

解决方案

其实我找到了一个更好的解决方案!

通过设置onClickListener(空);然后重新创建onResume,它绕过不必使用标志,什么不是。

!k来

Currently I'm experiencing a bug where if the user quickly taps a button, the intent that the button is attached to will fire off multiple times, resulting in a stack of that intent that will need to be back traced through again. How can I avoid this or remedy this?

Thanks ~k

This is inside of the onClickListener. I set the boolean value here, then I unset it at the end of the process.

        if(!isDating)
        {
            intent.setClass(context, EventDate.class);
            isDating = true;
            ((TabGroupActivity)
            context).startChildActivity("EventDate",intent);
        }

解决方案

Actually I found a better solution!

by setting the onClickListener(null); then recreating it onResume, it bypasses having to use flags and what not.

!k

这篇关于安卓:快速按钮presses导致意向的多个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆