我在Frame Layout中有一个Custom gridView和一个Button。代码如下
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@+id/Rel_Spinner"
android:layout_centerHorizontal="true"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" >
<Button
android:id="@+id/btnLoadMore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Load More" />
</FrameLayout>
</RelativeLayout>
它从适配器加载图像和文本。如图
现在我想要的是,当GridView Scroll的最终位置到达时,Button应该出现,否则它应该再次消失。如图所示。
答案 0 :(得分:0)
您可以使用setOnScrollListener将GridView用作:
gridview.setOnScrollListener(new OnScrollListener() {
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
switch(scrollState) {
case 2: // SCROLL_STATE_FLING
//hide button here
break;
case 1: // SCROLL_STATE_TOUCH_SCROLL
//hide button here
break;
case 0: // SCROLL_STATE_IDLE
//show button here
break;
default:
//show button here
break;
}
}
});