使用Android龙钮preSS递增/递减计数器 [英] Using an Android Long-Button press to increment/decrement counter

查看:209
本文介绍了使用Android龙钮preSS递增/递减计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够以preSS一个按钮在我的计划,并保持一段时间(不释放),以增加一个变量。问题我有现在的问题是,当我进行它只能运行一次漫长的按钮preSS,直到我再次释放和preSS。

首先,我想看看是否有办法做到这一点,而不必使用OnTouchListener,只是使用OnLongClick。有没有一种方法来检查按钮的价值?例如..的buttonDown = TRUE;进行一次whileloop递增,直到松开按钮。

其次,我不想被延迟了更新,因为增加的值被绘制为用户按住按钮

基本上我做这样的事情:

  btn_resume.setOnLongClickListener(新OnLongClickListener(){
公共布尔onLongClick(视图v){


.. code ..
返回true;

        }
    });
 

解决方案

如果我理解你的问题正确的这样一个使用OnLongClickListener来实现。

//:

您将在这里 HTTP找到答案www.rochdev.com/2011/05/update-ui-when-holding-button.html

I want to be able to press a button on my program and hold it down (without releasing) to increment a variable. Problem I am having right now is when I conduct the long button press it only runs once, until I release and press again.

First I want to find out if there is a way to do this without having to use the OnTouchListener, and just using the OnLongClick. Is there a way to check the value of the button? For example.. buttondown=true; Conduct a whileloop to increment until the button is released.

Second, I don't want the updates to be delayed, because the incremented value is being drawn as the user holds down the button.

Basically I am doing something like this:

btn_resume.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {


..code..
return true;

        }
    });

解决方案

If I understood your question correct this can be achieved using a OnLongClickListener.

You will find the answer here http://www.rochdev.com/2011/05/update-ui-when-holding-button.html

这篇关于使用Android龙钮preSS递增/递减计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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