scroll View To Top - Android User Interface

Android examples for User Interface:ScrollView

Description

scroll View To Top

Demo Code


import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.ScrollView;

public class Main{
    public static void scrollToTop(View view) {
        if (view instanceof ScrollView) {
            ScrollView scrollView = (ScrollView) view;
            scrollView.smoothScrollTo(0, 0);
        } else if (view instanceof ListView) {
            ListView listView = (ListView) view;
            listView.setSelection(0);/* www . j a  v a  2s . c  om*/
        }
    }
}

Related Tutorials