Android 如何知道用户是否在屏幕末端滚动

Android 如何知道用户是否在屏幕末端滚动,android,android-scrollview,Android,Android Scrollview,我试图知道用户何时在屏幕的末尾滚动 我的布局是ScrollView 我创建了新的Costum ScrollView对象,以覆盖onScrollChanged,并在此处使用代码: 我知道用户何时滚动到屏幕末尾的代码是: 我在我的滚动视图下方的布局中创建了名为checkEndOfList的视图 在我的代码中,我尝试检查列表的末尾是否显示 我的XML: <com.example.workoutlog.WallScrollView android:id="@+id/wallLi

我试图知道用户何时在屏幕的末尾滚动

我的布局是ScrollView

我创建了新的Costum ScrollView对象,以覆盖onScrollChanged,并在此处使用代码:

我知道用户何时滚动到屏幕末尾的代码是:

我在我的滚动视图下方的布局中创建了名为
checkEndOfList
的视图

在我的代码中,我尝试检查列表的末尾是否显示

我的XML:

 <com.example.workoutlog.WallScrollView
        android:id="@+id/wallList"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:stackFromBottom="true"
        android:transcriptMode="alwaysScroll" >

        <LinearLayout
            android:id="@+id/workoutsWall"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
        </LinearLayout>
    </com.example.workoutlog.WallScrollView>

    <LinearLayout
        android:id="@+id/checkEndOfList"
        android:layout_width="fill_parent"
        android:layout_height="0.1sp"
        android:layout_below="@+id/wallList"
        android:orientation="horizontal"
        android:background="@color/transparent" >
    </LinearLayout>
我试过的代码对我有用。即使我没有在屏幕上滚动,我也会接到屏幕结束的电话

谢谢您的帮助。

您可以这样使用:

    private int visibleThreshold = 5;
    private int currentPage = 0;
    private int previousTotal = 0;
    private boolean loading = true;

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem,
            int visibleItemCount, int totalItemCount) {
        if (loading) {
            if (totalItemCount > previousTotal) {
                loading = false;
                previousTotal = totalItemCount;
                currentPage++;
            }
        }
        if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {
            // I load the next page of gigs using a background task,
            // but you can call any function here.
            new LoadGigsTask().execute(currentPage + 1);
            loading = true;
        }
    }
private int visibleThreshold=5;
private int currentPage=0;
private int previousTotal=0;
私有布尔加载=真;
@凌驾
public void onScroll(AbsListView视图,int firstVisibleItem,
int visibleItemCount,int totalItemCount){
如果(装载){
如果(totalItemCount>previousTotal){
加载=假;
previousTotal=totalItemCount;
currentPage++;
}
}
如果(!loading&&(totalItemCount-visibleItemCount)
    private int visibleThreshold = 5;
    private int currentPage = 0;
    private int previousTotal = 0;
    private boolean loading = true;

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem,
            int visibleItemCount, int totalItemCount) {
        if (loading) {
            if (totalItemCount > previousTotal) {
                loading = false;
                previousTotal = totalItemCount;
                currentPage++;
            }
        }
        if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {
            // I load the next page of gigs using a background task,
            // but you can call any function here.
            new LoadGigsTask().execute(currentPage + 1);
            loading = true;
        }
    }