ListView的表示更滚动itmes [英] ListView Indicate more scrollable itmes

查看:111
本文介绍了ListView的表示更滚动itmes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有我想要做的就是当页面有更多的数据,应该有像三个点的一些指示或类似的东西在页面的底部,这样用户就知道有更多的记录,并滚动它。

all i want to do is When the page has more data, there should be some indication like three dots or something like that at the bottom of the page so that user will know there are more records and will scroll it

这里在页面的底部,没有任何迹象表明,有更多的
记录。我想,当有更多的数据添加指示签名。

here At the bottom of the page there is no indication that there are more records. i want to add that indication signature when there are more data.

推荐答案

一个可能的解决方案是增加你的ListView下方的视图(与一个TextView或ImageView的布局):

A possible solution is to add a View (a layout with a textView or ImageView) beneath your ListView:

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1" >
</ListView>
<LinearLayout
    android:id="@+id/viewid"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0" />

的权重是很重要的,以显示两个组件。
在此之后,实现了ListView的onScrollListener。

The weights are important to show both components. After that, implements the listView's onScrollListener.

setOnScrollListener(new OnScrollListener() {
    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        //get the showed item num, and if its equal to total, you can hide the view
        //get a reference to your viewid
        viewid.setVisibility(View.GONE);
    }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {

    }
});

当它到达了底部的查看最后一行,setVisibility(View.GONE)。
如果你想再次显示由此看来,当用户滚动起来,修改code。当然,你可以使用aother布局,一个TextView,或别的东西。

When it reaches the last line, setVisibility(View.GONE) for the bottom View. If you want to show this View again, when user scrolls up, modify the code. Of course, you can use aother layout, a textView, or something else.

更新

我打了一个布局一点点,并没有为您的布局文件,其中底部的观点是覆盖ListView中的其他解决办法,所以这个的TextView的去除是平稳的。

I played with the a layout a little bit, and there is an other solution for your layout file, where the bottom View is overlaying the listView, so the removing of this textView is smooth.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>
    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:padding="5dp"
        android:background="#ffffff"
        android:layout_alignParentBottom="true"
        android:text="..." />
</RelativeLayout>

这篇关于ListView的表示更滚动itmes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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