ListView 基本用法
|
|
|
|
完整demo
|
|
运行效果
初始状态。
onPress触发后
注意
cloneWithRows接受一个数组
renderRow,hightlightRow & renderSeparator
renderRow 的回调函数可以接受4个参数,分别是数据,区块id,行id,highlightRow回调函数
其中hightlightRow的用法文档里面写的不是很明白。搜了一下,发现是这样用的
http://stackoverflow.com/questions/36000842/how-do-i-call-highlightrow-of-listview-renderrow
大致过程是这样的,如果触发了hightlightRow(sectionID,rowID)函数,则会将该sectionID,rowID相应的单元行的标记为highlighted。而renderSeparator会检查每一个row的相邻row的highlight情况,也就是adjacentRowHighlighted 的真假。adjacentRowHighlighted默认为false
文档对renderSeparator的解释
renderSeparator function #
(sectionID, rowID, adjacentRowHighlighted) => renderable
如果提供了此属性,一个可渲染的组件会被渲染在每一行下面,除了小节标题的前面的最后一行。在其上方的小节ID和行ID,以及邻近的行是否被高亮会作为参数传递进来。(sectionID, rowID, adjacentRowHighlighted) => renderable
If provided, a renderable component to be rendered as the separator below each row but not the last row if there is a section header below. Take a sectionID and rowID of the row above and whether its adjacent row is highlighted.
|
|
这块代码表示了当adjacentRowHighlighted为true时,该view(分割线)的颜色为蓝色。
另外
http://wiki.jikexueyuan.com/project/react-native/image.htm
中的uri的用法