获得一个按钮,滚动到视图在一个GridView的Andr​​oid上的底部 [英] Getting a button to scroll into view at the bottom of a GridView on Android

查看:86
本文介绍了获得一个按钮,滚动到视图在一个GridView的Andr​​oid上的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图端口一个现有的iPhone应用程序到Android。我想有一个按钮滚动到视图在一个GridView的底部,以使用户从服务器加载更多的数据。 presently,我的解决方案只需在屏幕的底部修复了按钮,而不是让它滚动到视图中。

I am trying to port an existing iPhone application to android. I wish to have a button scroll into view at the bottom of a GridView to enable the user to load more data from the server. Presently, my solution simply fixes a button at the bottom of the screen instead of having it scroll into view.

下面是我的布局code:

Here is my layout code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"    
        >   
        <GridView xmlns:android="http://schemas.android.com/apk/res/android" 
            android:id="@+id/grid"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            android:columnWidth="70dp"
            android:numColumns="auto_fit"
            android:verticalSpacing="0dp"
            android:horizontalSpacing="0dp"
            android:stretchMode="columnWidth"
            android:gravity="center"
            android:background="#000000"
        />
        <Button
        android:id="@+id/load_more"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:text="Load More" 
        />
    </LinearLayout>

在屏幕底部的固定按钮不起作用,因为我计划刊登广告在底部。

Fixing the button at the bottom of the screen won't work because I plan on placing an ad at the bottom.

任何人都可以向您解释概念如何获得负载更多的按钮,滚动到视图,或点我一些样本code,或者告诉我这是为什么不地道于Android和它所使用的其他UI约定加载在GridView更多的数据?

Can anyone either explain conceptually how to get a load more button to scroll into view, or point me to some sample code, OR tell me why this is not idiomatic to Android and what other UI convention it uses to load more data in a GridView?

谢谢!

推荐答案

我有一个滚动GridView和刷新基础数据,注意到该scoll没有恢复到开始后类似的问题。我用下面的code片段解决了这个问题。

I had a similar problem with scrolling a GridView and after refreshing the underlying data, noticing that the scoll was not reset to the beginning. I solved it with the following code fragment

gvKeys.setSelection(0);

我猜,如果你知道你的网格项目的数量, N ,那下面的工作:

gvKeys.setSelection(N);

这篇关于获得一个按钮,滚动到视图在一个GridView的Andr​​oid上的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆