I added a HorizontalScrollView in xml and I want to disable scrolling on button click and enable again on another button click.
Disabling scrolling with button click works but I don't know how to enable scrolling again.
The code below is how disabling scrolling worked.
class OnTouch implements View.OnTouchListener { @Override public boolean onTouch(View v, MotionEvent event) { return true; } } I added the above class and then,
final HorizontalScrollView scrollView = (HorizontalScrollView)findViewById (R.id.horizontalScrollView); Button stop = (Button)findViewById(R.id.stop); stop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { scrollView.setOnTouchListener(new OnTouch()); } }); I added the above code inside onCreate method. I want to add another button(maybe "scroll") and I want that button to enable scrolling again.