RecyclerView实现 ListView,GridView,瀑布流效果

RecyclerView 是Google推出的最新的 替代ListView、GridView的组件,RecyclerView是用来显示大量数据的容器,并通过有限数量的子View,来提高滚动时的性能。

与ListView不同,RecyclerView 不再负责布局,而是专注于布局复用。布局主要通过 LayoutManager来管理,目前提供了3种常用的布局管理:

  • LinearLayoutManager 线性布局管理器 (ListView效果)
  • GridLayoutManager 网格布局管理器 (GridView效果)
  • StaggeredGridLayoutManager 瀑布流管理器

    Read More

ListView默认选中某一项

给选中的Item添加效果(For API 11+):

  1. Set list view to single choice:
    <ListView android:choiceMode="singleChoice" />

  2. Set the background of the root element of your item layout to your selector:
    <LinearLayout android:background="@drawable/selector">

    Read More