如何尽快禁用按钮,它被点击

编程入门 行业动态 更新时间:2024-10-23 13:31:46
本文介绍了如何尽快禁用按钮,它被点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个按钮,在点击加载另一个活动,但它加载,如果我继续挖掘它的另一个活动之前,则启动活动,但同样的活动被加载两次以上。 我曾尝试button.setEnabled(假)后不久button.setOnClickListener ...的onClick 但那不是禁用按钮,我也是只要按钮被窃听记录的文本,因此这取决于我的水龙头,它记录的文字2〜3次,即使我已经拍了拍它的10倍。 我觉得这里是之前的按钮可以收听挖掘事件,我是攻是如此之快,监听所有这些事件多次我点击它。

I have a button which on Click loads another activity, but before it loads another Activity if i tap it continuously, then it launches the activity but the same activity is loaded two times or more. I have tried button.setEnabled(false) soon after button.setOnClickListener...onClick but that is not disabling the button, i am also logging a text as soon as the button is tapped, thus depending on my taps it logs the text 2 or 3 times even if i had tapped it 10 times. What i feel here is before the button can listen to tap events, i am tapping it so fast that it listens to all those events as many times as i tap it.

因此​​我需要的东西在这里的按钮就可以只听一个水龙头,然后将其禁用。

Thus i need something where the button can just listen one tap and then disable it.

请帮忙

推荐答案

其称为issue.Basicallyü可以设置标志。

Its known issue.Basically u can set the flag.

int flag=1; @Override public void onClick(View v) { if(flag) { button.setEnabled(false); Log.d("ins", "called"); } flag=0; }

更多推荐

如何尽快禁用按钮,它被点击

本文发布于:2023-11-29 23:13:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647919.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按钮

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!