android大讲堂——listview详解

本期讲解listview控件,包含基本用法、回调方法、页眉页脚等

1、基本用法

a) 官方定义:A view that shows items in a vertically scrolling list. The items come from the ListAdapter associated with this view.

b) 五个xml属性:

android:dividerDrawable or color to draw between list items. 

android:dividerHeightHeight of the divider. 

android:entriesReference to an array resource that will populate the ListView. 

android:footerDividersEnabledWhen set to false, the ListView will not draw the divider before each footer view. 

android:headerDividersEnabledWhen set to false, the ListView will not draw the divider after each header view. 

android:scrollbars: 滚动条的显示方式(垂直、水平、无)

android:fastScrollEnabled:是否快速滑动

android:minHeight,android:minWidth:最小高宽

c) 父类

java.lang.Object

android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.AdapterView<T extends android.widget.Adapter>
         ↳ android.widget.AbsListView
           ↳ android.widget.ListView

d)公共构造函数

public ListView (Context context)
public ListView (Context context, AttributeSet attrs)
public ListView (Context context, AttributeSet attrs, int defStyle)
e) 公共方法

addFooterView(View v) addHeaderView(View v) 添加页眉页脚(还有删除)

getFooterViewsCount() getHeaderViewsCount() 获得页眉页脚的个数



2、回调方法

setOnItemClickListener:每一项点击事件监听
setOnLongClickListener:长按事件监听

3、页眉页脚

基本可实现的效果,如:上拉刷新、下拉加载更多、listview顶部添加图片或自定义布局

















  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

韩小浪~~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值