react native SectionList 使用详解
来源:互联网 发布:手机键盘软件 编辑:程序博客网 时间:2024/06/07 10:35
SectionList 和FlatList的基本一样,和FlatList一样的地方就不介绍啦。那什么时候使用FlatList,什么时候使用SectionList呢?如果你的列表不需要分组,那么可以使用结构更简单的 FlatList。
在0.43版本中,如果希望section的头部能够吸顶悬浮,请暂时先使用老版的 ListView。下一个版本开始可以支持悬浮的section头部。
属性:
SectionSeparatorComponent:组之间的分割控件
renderSectionHeader:组的头部
sections:列表的数据
Demo:
import React, {Component} from 'react';import { StyleSheet, View, Text, SectionList,} from 'react-native';export default class SectionListDemo extends Component { _renderItem = (info) => { var txt = 'index:' + info.index + ' ' + info.item.title; var bgColor = info.index % 2 == 0 ? 'red' : 'blue'; return <Text style={{height:100,textAlignVertical:'center',backgroundColor:bgColor,color:'white',fontSize:15}}>{txt}</Text> } _sectionComp = (info) => { var txt = 'key:' + info.section.key; return <Text style={{height:50,textAlign:'center',textAlignVertical:'center',backgroundColor:'black',color:'white',fontSize:30}}>{txt}</Text> } render() { var sections = []; for (var i = 0; i < 10; i++) { var datas = []; for (var j = 0; j < 10; j++) { datas.push({title: 'title:' + j}); } sections.push({key: i, data: datas}); } return ( <View style={{flex:1}}> <SectionList renderSectionHeader={this._sectionComp} renderItem={this._renderItem} sections={sections}/> </View> ); }}
效果图:
其余属性请查看FlatList
github下载地址
1 0
- react native SectionList 使用详解
- React-Native SectionList使用
- react-native SectionList的使用
- 细说react-native中的SectionList
- ReactNative SectionList使用详解
- React Native使用SectionList打造城市选择列表,包含分组的跳转
- 学习总结 ~ (三)React Native 初学 之 sectionList
- react native ActivityIndicator使用详解
- react native Button 使用详解
- react native Text 使用详解
- react native Switch使用详解
- react native ScrollView 使用详解
- react native FlatList 使用详解
- react native TextInput 使用详解
- react native Slider 使用详解
- react native StatusBar 使用详解
- react native DatePickerIOS 使用详解
- react native DrawerLayoutAndroid 使用详解
- c/c++ No.21 查找任意一个字符
- jQuery.extend 函数使用详解
- 指针的问题
- 《Cracking the Coding Interview程序员面试金典》----确定两串乱序同构
- Domai adaptation 相关的句子
- react native SectionList 使用详解
- HDU 2859 Phalanx (DP)
- c/c++ No.22 查找子串
- content="IE=edge,chrome=1">含义
- 【DVB】DVB-T系统的参数和搜台介绍
- Java 调用外部程序
- WPF学习之深入浅出话命令
- VM下载与安装,破解
- 进不去的城市,回不了的老家,该何去何从?