【android API】 ListView api 翻译

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;

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值