本文轉載於:http://blog.csdn.net/vector_yi/article/details/23195411java
近期在從新學習Android控件知識,目前進行到ListView,感受這是一塊尤爲難啃的硬骨頭:最爲經常使用、用法較複雜、涉及的其餘Android知識也較多。所以決定系統地好好複習一遍ListView。其中涉及到的其餘知識點將在後期以連接的形式不斷進行更新。android
本文僅介紹ListView相關的XML屬性及方法,數組
關於ListView在App中的用法:Android ListView 常見用法。緩存
關於ListView中須要注意的地方,請移步:ListView中幾個須要注意的屬性.
ide
1、ListView類的繼承關係佈局
能夠看出,ListView並不直接繼承於View,而是直接繼承於抽象類AbsListView.學習
ListView的直接子類有:ExpandableListView.優化
2、ListView概述動畫
ListView是一個用來縱向顯示條目的視圖,這些條目內容來自於與該ListView相關聯的ListAdapter.spa
3、嵌套類
- class ListView.FixedViewInfo
4、XML屬性
1.ListView的XML屬性
- android:divider
-
- android:dividerHeight
-
- android:entries
-
- android:footerDividersEnabled
-
- android:headerDividersEnabled
2.繼承自AbsListView的XML屬性
- android:cacheColorHint
-
- android:choiceMode
-
- android:drawSelectorOnTop
-
- android:fastScrollEnabled
-
- android:listSelector
-
- android:scrollingCache
-
-
- android:smoothScrollbar
-
- android:stackFromBottom
-
- android:textFilterEnabled
-
- android:transcriptMode
-
-
-
3.繼承自ViewGroup的XML屬性
- android:addStatesFromChildren
-
- android:alwaysDrawnWithCache
-
- android:animationCache
-
- android:clipChildren
-
- android:clipToPadding
-
- android:descendantFocusability
-
-
-
-
- android:layoutAnimation
-
- android:persistentDrawingCache
-
-
-
-
-
-
4.繼承自View的XML屬性
太多了………………饒過我吧
5、經常使用public方法
1.add/remove 方法
- void addFooterView(View v)
-
- void addFooterView(View v,Object data,boolean isSelectable)
-
-
- void addHeaderView(View v)
-
- void addHeaderView(View v,Object data,boolean isSelectable)
-
- boolean removeFooterView(View v)
-
- boolean removeHeaderView(View v)
2.響應事件方法
- boolean OnKeyDown(int keyCode,KeyEvent event)
-
- boolean OnKeyMultiple(int keyCode,int repeatCount,KeyEvent event)
-
- boolean OnKeyUp(int keyCode,KeyEvent event)
3.get方法
- ListAdapter getAdapter()
-
- Drawable getDivider()
-
- int getDividerHeight()
-
- int getFooterViewCount()
-
- int getHeaderViewCount()
-
- boolean getItemsCanFocus()
-
- int getMaxScrollAmount()
-
- Drawable getOverscrollFooter()
-
- Drawable getOverscrollHeader()
4.set方法
- void setAdapter(ListAdapter adapter)
-
- void setCacheColorHint(int color)
-
- void setDivider(Drawable divider)
-
- void setDividerHeight(int height)
-
- void setFooterDividerEnabled(boolean footDividerEnabled)
-
- void setHeaderDividerEnabled(boolean headDividerEnabled)
-
- void setItemsCanFocus(boolean itemsCanFocus)
-
- void setOverscrollFooter(Drawable footer)
-
- void setOverscrollHeader(Drawable header)
-
- void setRemoteViewAdapter(Intent intent)
-
- void setSelection(int position)
-
- void setSelectionAfterHeaderView()