ensure ListView Visible by position - Android android.widget

Android examples for android.widget:ListView

Description

ensure ListView Visible by position

Demo Code

import android.widget.ListView;

public class Main{

    public static void ensureVisible(ListView list, int positionToShow) {

        if (positionToShow < list.getFirstVisiblePosition()
                || positionToShow > list.getLastVisiblePosition()) {
            list.setSelection(positionToShow);
        }//from ww w.  j a  v  a2  s .  c  o  m
    }

}

Related Tutorials