Android之listview下拉刷新

       很久没有更新了,老是忘记,哈哈。。。。。

      那么今天就说一说listview的下拉刷新,通过这个我们可以学习到自定义view的一些属性,还有需要重写的一些方法,以及这些方法的作用。

虽然现在已经有下拉刷新的一些成熟的库了,例如PullToRefresh,有空你们可以去试一下,这个就比较简单了,只需调用里面的方法就可以实现下拉刷新的功能。

有兴趣的朋友可以学习一下。

个人觉得我这个其实有一点点的麻烦,但毕竟是自己刚开始的时候第一次写的一个自定义view,所以拿出来跟你们分享分享。下面就先贴出我的xml文件中的代码吧,必要的地方我会一些注释的。


这个是主页面的xml文件,是自定义listview的包名,

<com.example.reflashlistview.FlashListView
        android:id="@+id/ll"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        
        />



这个是listview的item的布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >
    
    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher"
        />
    
    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="25dp"
        android:textColor="#66ff0000"
        android:text="文本一"
        />
    

</LinearLayout>

这个是头布局的文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        >
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_centerInParent="true"
            android:id="@+id/linear"
            >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="下拉可以刷新"
               android:id="@+id/update"
                />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/updatetime"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值