Android TextVIew scrolling while a button remains in pressed state
<p>I want to scroll a <code>textview</code> while a <code>button</code> is in pressed state. As soon as user releases the <code>button</code>, I want to stop scrolling. I am using <code>setOnTouchListener</code> on the button. But I am unable to achieve that. Can anyone please help me and share some code to do this.</p>

<pre><code>arrow_up.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    lastDown = System.currentTimeMillis();
                    System.out.println(System.currentTimeMillis());
                flag = true;
                method();
                } else if (event.getAction() == MotionEvent.ACTION_UP) {
                    System.out.println(System.currentTimeMillis() - lastDown);
                    flag = false;
                    method();
                }
                return false;
            }
        });

public void method() {
        while(flag == true){

            try {
                Thread.sleep(500);
                System.out.println("Flag === " + flag);
                tv.scrollBy(0, -20);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        }
</code></pre>
