To create complex lists and cards with material design styles in your apps, you can use the RecyclerView and CardView widgets.//想要创建 ...
To create complex lists and cards with material design styles in your apps, you can use the RecyclerView
and CardView
widgets.
//想要创建复杂的带有material design风格的列表,使用RecyclerView
和 CardView widget
Create Lists
The RecyclerView
widget is a more advanced and flexible version of ListView
. This widget is a container for displaying large data sets that can be scrolled very efficiently by maintaining a limited number of views. Use the RecyclerView
widget when you have data collections whose elements change at runtime based on user action or network events.
The RecyclerView
class simplifies the display and handling of large data sets by providing:
- Layout managers for positioning items
- Default animations for common item operations, such as removal or addition of items //对移除或者添加等常用条目的行为都有默认的动画
You also have the flexibility to define custom layout managers and animations for RecyclerView
widgets.
Figure 1. The RecyclerView
widget.
To use the RecyclerView
widget, you have to specify an adapter and a layout manager. To create an adapter, extend the RecyclerView.Adapter
class. The details of the implementation depend on the specifics of your dataset and the type of views. For more information, see the examples below.
Figure 2 - Lists with RecyclerView
.
@Override // use this setting to improve performance if you know that changes // use a linear layout manager // specify an adapter (see also next example) // Provide a reference to the views for each data item // Provide a suitable constructor (depends on the kind of dataset) // Create new views (invoked by the layout manager) // Replace the contents of a view (invoked by the layout manager) } // Return the size of your dataset (invoked by the layout manager) <TextView
原标题:Creating Lists and Cards 创建列表和卡片
关键词:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。