ListView虽然常用,可是还没有系统的知道他。先从API开始吧。http://developer.android.com/reference/android/widget/ListView.html

略过summary了,直接进入xml attribute。

A.Xml Attribute。

1,android:divider

Drawable or color to draw between list items. 画在list的items之间的图片或颜色。

May be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".可以引用图片资源

May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb".可以使用颜色值。

This corresponds to the global attribute resource symbol divider.这相当于全局R.attr中的divider,其默认值:Constant Value: 16843049 (0x01010129)

2,android:dividerHeight

Height of the divider. Will use the intrinsic height of the divider if this is not specified.分割的高度。如果没有指明,那么使用默认的。

Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), mm (millimeters).必须使用浮点数,想14.5sp。可用的单位还有px,dp,sp,in,mm。

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.可以使用包含这类型值的资源引用。

This corresponds to the global attribute resource symbol dividerHeight.全局默认值:Constant Value: 16843050 (0x0101012a)

3,android:entries

Reference to an array resource that will populate the ListView. For static content, this is simpler than populating the ListView programmatically.

引用一个数组的资源,填入ListView。如果数组是固定的,那么在属性中使用比在程序中要简单。

Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".必须以这种形式引用其他的资源。

This corresponds to the global attribute resource symbol entries.全局默认:Constant Value: 16842930 (0x010100b2)

4,android:footerDividersEnabled

When set to false, the ListView will not draw the divider before each footer view. The default value is true.如果值为false,那么ListView不会在footer view 展示前显示分割。默认为true。

Must be a boolean value, either "true" or "false".true,false二选一,没有其他值。

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.也可引用带有boolean值的资源。

This corresponds to the global attribute resource symbol footerDividersEnabled.全局默认:你懂的。

5,android:headerDividersEnabled  (翻译同4)

When set to false, the ListView will not draw the divider after each header view. The default value is true.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol headerDividersEnabled.

B.public constructors

public ListView (Context context) ; public ListView (Context context, AttributeSet attrs);

public ListView (Context context, AttributeSet attrs, int defStyle)
C.public method

1,public void addFooterView (View v) 参数是要添加的view

Add a fixed view to appear at the bottom of the list. If addFooterView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.

Note: When first introduced, this method could only be called before setting the adapter with setAdapter(ListAdapter). Starting with KITKAT, this method may be called at any time. If the ListView's adapter does not extendHeaderViewListAdapter, it will be wrapped with a supporting instance of WrapperListAdapter.

在list的底部添加一个固定的视图。如果该方法被多次调用,所加的视图,将按照他们被加入的顺序排列。加入的视图可以获取焦点。

注意:第一次介绍的时候,该方法只能在setAdapter之后调用。但是在api19后,该方法可以被任意时间调用。如果ListView的adapter没有集成HeaderViewListAdapter,他将被包含在一个支持WrapperListAdapter的实例中。

2,public void addFooterView (View v, Object data, boolean isSelectable) 要添加的View,要添加的数据,是否可以被选中

Add a fixed view to appear at the bottom of the list. If addFooterView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.

Note: When first introduced, this method could only be called before setting the adapter with setAdapter(ListAdapter). Starting with KITKAT, this method may be called at any time. If the ListView's adapter does not extendHeaderViewListAdapter, it will be wrapped with a supporting instance of WrapperListAdapter.

3,public void addHeaderView (View v, Object data, boolean isSelectable) 要添加的View,要添加的数据,是否可以被选中

Add a fixed view to appear at the top of the list. If this method is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.

Note: When first introduced, this method could only be called before setting the adapter with setAdapter(ListAdapter). Starting with KITKAT, this method may be called at any time. If the ListView's adapter does not extendHeaderViewListAdapter, it will be wrapped with a supporting instance of WrapperListAdapter.

4,public void addHeaderView (View v) 要添加的view

Add a fixed view to appear at the top of the list. If addHeaderView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.

Note: When first introduced, this method could only be called before setting the adapter with setAdapter(ListAdapter). Starting with KITKAT, this method may be called at any time. If the ListView's adapter does not extendHeaderViewListAdapter, it will be wrapped with a supporting instance of WrapperListAdapter.

5,public boolean areFooterDividersEnabled ()

  • Whether the drawing of the divider for footer views is enabled

分割线是否适用与footerView。true or false

6,public boolean areHeaderDividersEnabled ()

  • Whether the drawing of the divider for header views is enabled

7,public boolean dispatchKeyEvent (KeyEvent event) 若事件被处理,true; 否则为false。

Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.

将按键事件分配,按照获取焦点顺序的规则。该顺序为从树的顶部到当前获取焦点的view。如果当前视图拥有焦点,该事件分配于己身。否则,他将分配给下一个将要获取焦点的节点。此方法将会触动所有的按键监听器。

8,public ListAdapter getAdapter ()

Returns the adapter currently in use in this ListView. The returned adapter might not be the same adapter passed to setAdapter(ListAdapter) but might be a WrapperListAdapter.

返回当前ListView使用的adapter。该返回的未必是setAdapter中的adapter,也许是WrapperListView。

9,public long[] getCheckItemIds ()

This method was deprecated in API level 8.
Use getCheckedItemIds() instead.

Returns the set of checked items ids. The result is only valid if the choice mode has not been set to CHOICE_MODE_NONE.

api 8 之后已经被getCheckedItemIds代替。

返回被选中项目的索引集合。当choice mode 没有被设置为 CHOICE MODE NONE的时候结果才有效。

10,public Drawable getDivider ()

Returns the drawable that will be drawn between each item in the list.返回将要显示在list的item之间的分割线。

11,public int getDividerHeight ()

  • Returns the height of the divider that will be drawn between each item in the list.

返回分割线的高度。我理解为分割线相对于两个item的间距。

12,public int getFooterViewsCount ()

Returns the number of footer views in the list. Footer views are special views at the bottom of the list that should not be recycled during a layout.

通过方法名貌似一目了然。获取footer view 的数量。footer views是特殊的view添加在lsit的底部,在当前布局下,不应该被回收。

13,public int getHeaderViewsCount ()

Returns the number of header views in the list. Header views are special views at the top of the list that should not be recycled during a layout.同12.

14,public boolean getItemsCanFocus ()

  • Whether the views created by the ListAdapter can contain focusable items.

ListAdapter创建的view是否可以包含可获取焦点的条目。

15,public int getMaxScrollAmount ()

  • The maximum amount a list view will scroll in response to an arrow event.

/**
* @return The maximum amount a list view will scroll in response to
* an arrow event.
*/
public int getMaxScrollAmount() {
return (int) (MAX_SCROLL_FACTOR * (mBottom - mTop));
}/**

* When arrow scrolling, ListView will never scroll more than this factor times the height of the list.

当箭头滚动,ListView将永远不会滚动超过这个常量的倍数。
*/
private static final float MAX_SCROLL_FACTOR = 0.33f;

转载于:https://www.cnblogs.com/outOfview/p/3475807.html

【android API】 ListView api 翻译相关推荐

  1. Android自定义ListView示例,以创建不可滚动的ListView

    In this tutorial we'll override the ListView class to suit it according to our requirements in the a ...

  2. 翻译Android USB HOST API

    翻译Android USB HOST API 源码地址:http://developer.android.com/guide/topics/connectivity/usb/host.html 译者注 ...

  3. Android 5.0 API 的变化——开发人员注意

    Android 5.0 API变化 译自 http://developer.android.com/intl/zh-cn/about/versions/android-5.0.html -- By N ...

  4. Android各个版本API的区别

    Android各个版本API的区别 Android 1.5 API变更概要: 1.UI framework · Framework for easier background/UI thread in ...

  5. Android百度地图API使用教程

    课1 百度地图应用 百度地图.ppt 百度地图API:API文档 http://wiki.lbsyun.baidu.com/cms/androidsdk/doc/v3_2_0/ 67个类:其中6大核心 ...

  6. Android Google Maps API教程-入门

    This is android google maps api tutorial. 这是android Google Maps API教程. In this tutorial I will teach ...

  7. Android中所有API和对应权限的数据结构构建

    #写在前面的话 这是一篇有毒博客,我觉得,读者慎入. 我想说,那个最底下的广告怎么去,辣眼睛- T -T 当然,你也可以帮我点下我的,在这里跪谢大家 https://www.captainbed.ne ...

  8. Android 操作串口 (android serial port api)

    Android 操作串口 (android serial port api)

  9. Android 2.3 API改变大全(转载)

    遇到OOM问题,需要使用VMRuntime类的时候才发现,原来2.3被移除了,想知道它是否有替代类?留下脚印,再继续... Android 2.3 API改变大全 作者: Android开发网原创 时 ...

最新文章

  1. 使用GIF(仅限Delphi2007)
  2. ROS系统 C++或Python实现话题消息的定义与使用
  3. groovy定义变量获取当前时间_IDEA不愧为神器,结合Groovy脚本,简直无敌!
  4. DL之RNN:循环神经网络RNN的简介、应用、经典案例之详细攻略
  5. 两个byte[]拼接
  6. 关于centos6升级python3.6无法使用pip的问题
  7. Makefile.am
  8. 数据库设置_CentOS7 - 设置MySQL数据库
  9. C# CollectionBase,ICloneeable
  10. wincc怎么做数据库_关于WINCC通过PLCSIM来进行仿真中要怎么设置?
  11. JavaSceipt核心语法——运算符
  12. python日期模块datetime常用操作总结(字符串与datetime对象互转、日期差值计算、时间戳获取、时间数组生成等)
  13. linux c 获取终端输出到文件,LINUX C获取命令行输出结果
  14. GNS3模拟ASA8.4 ASDM6.4QEMU模拟 终结版
  15. uC/OS-II任务调度之就绪表及最高优先级任务判定算法
  16. RobotFramework(RF)常用函数库-内置库篇
  17. 台积电偷笑:就算Intel技术牛我也要赶超你
  18. 5.Linux下的权限管理
  19. 基于javaweb的药品进货销售管理系统(java+ssm+html+js+jsp+mysql)
  20. java遍历类属性,并给字段赋值

热门文章

  1. nopi 的使用记录
  2. c语言程序设计案例教程(第2版)笔记(三)—变量、结构体
  3. linux dmesg命令参数及用法详解(linux显示开机信息命令)
  4. Ajax、Comet与Websocket
  5. goto VS longjmp setjmp
  6. OpenGL鼠标拾取
  7. android 网络广播 类似QQ动态检查网络
  8. php session 过期,php session失效的原因
  9. 大年30还多少天_2020余额不足30天!年初许下的愿望你实现了多少?
  10. Java学习笔记29