get ListView Up Scroll - Android User Interface

Android examples for User Interface:ListView

Description

get ListView Up Scroll

Demo Code


//package com.java2s;

import android.widget.ListView;

public class Main {
    public static void getListViewUpScroll(ListView listview) {
        int first = listview.getFirstVisiblePosition();
        int last = listview.getLastVisiblePosition();

        if (last - first >= 3) {
            int toggle = first - ((last - first + 1) - 2);


            listview.smoothScrollToPositionFromTop(toggle, 0);
        } else {/* w  w w. ja v a2 s. co m*/
            listview.smoothScrollBy(
                    -(listview.getHeight() - listview.getHeight() / 10),
                    500);
        }
    }
}

Related Tutorials