繁体   English   中英

使onTouchListener更新?

[英]Make onTouchListener to update?

我尚未找到要解决的答案。 只要按下按钮,我就想更新代码,放开时,代码停止更新。 任何建议都可以帮助。 这是我的代码:

forward.setOnTouchListener(new View.OnTouchListener() {


        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                // Code updates every frame
                return true;
            } else if (event.getAction() == MotionEvent.ACTION_UP){
                // Code stops updating
                return true;
            }
            return true;
        }


    });

这是示例:

 button1.setOnTouchListener(new View.OnTouchListener() {


    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {

            text1.setText("Text1");
        } else if (event.getAction() == MotionEvent.ACTION_UP) {

            text1.setText("Text2");
        }
        return true;
    }


});

暂无
暂无

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

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