Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use AutoScrollHelper

I recently found that the v4 library has a utility class AutoScrollHelper, and its subclass is ListViewAutoScrollHelper. Does anyone have a demo for this?

like image 542
Septenary Avatar asked Dec 10 '13 02:12

Septenary


1 Answers

AutoScrollHelper is a View.OnTouchListener.

A simple implementation using ListViewAutoScrollHelper would look something like this:

    final ListView list = (ListView) findViewById(android.R.id.list);
    final ListViewAutoScrollHelper scrollHelper = new ListViewAutoScrollHelper(list);
    scrollHelper.setEnabled(true);
    list.setOnTouchListener(scrollHelper);

To begin scrolling, touch your finger near the top (to scroll up) or bottom (to scroll down) edge of the screen and keep it pressed for the amount of time you'd like to remain scrolling.

like image 60
adneal Avatar answered Sep 19 '22 04:09

adneal