《ReactNative》之SectionList的简单使用
来源:互联网 发布:阿里云cdn如何配置 编辑:程序博客网 时间:2024/06/05 02:07
1.效果截图
2.完整代码
import React,{Component} from 'react';import{StyleSheet, View, Text, SectionList,} from 'react-native';export default class Contact extends Component{constructor(props){ super(props); } componentWillMount(){ } _renderItemComponent = ({item}) => { console.log(item); return( <View style={{flexDirection:'row'}}> <Text style={{marginRight:20}}>{item.name}</Text> <Text>{item.phone}</Text> </View> ); } _sectionHeader = ({section})=>{ return( <View> <Text style={{backgroundColor:'#f0f0f0',color:'#00bfff'}}>{section.key}</Text> </View> ); } render(){ var sections = []; var dataA = []; dataA.push({name:'安建文',phone:'18992131120',key:'1'}); dataA.push({name:'安周平',phone:'13212345678',key:'2'}); sections.push({key:'A',data:dataA}); var dataB = []; dataB.push({name:'白万剑',phone:'18992131121',key:'3'}); dataB.push({name:'白浩江',phone:'13212345678',key:'4'}); sections.push({key:'B',data:dataB}); var dataC = []; dataC.push({name:'蔡文姬',phone:'18192131123',key:'5'}); dataC.push({name:'曹操',phone:'13212345679',key:'6'}); sections.push({key:'C',data:dataC}); return ( <View style={{marginLeft:5,marginRight:5,}}> <SectionList renderItem={this._renderItemComponent} renderSectionHeader={this._sectionHeader} sections={sections} /> </View> ); } }
阅读全文
2 0
- 《ReactNative》之SectionList的简单使用
- ReactNative SectionList使用详解
- ReactNative的分组ListView-----SectionList
- ReactNative分组列表SectionList使用详情及示例详解
- ReactNative分组列表SectionList使用详情及示例详解
- react-native SectionList的使用
- reactnative之AsyncStorage,简单使用以及坑
- 史上最易懂——ReactNative分组列表SectionList使用详情及示例详解
- ReactNative中SectionList实现条目GridView效果
- React-Native SectionList使用
- ReactNative开发之DrawerLayoutAndroid组件的使用
- ReactNative之Flux框架的使用
- reactNative 开发之按钮的使用
- 《ReactNative》之Redux框架的使用
- 简单的ReactNative工程
- ReactNative-Navigator组件简单使用
- ReactNative中Redux简单使用
- react native SectionList 使用详解
- 【脚本语言系列】关于Python图像处理PIL,你需要知道的事
- 如何不绑定脚本且不继承MonoBehaviour做U3D的开发
- hibernate开发步骤
- MediaStream,AudioTrack,VideoTrack的关系
- 微信内嵌网页 签名生成 js-sdk开发
- 《ReactNative》之SectionList的简单使用
- 分支限界算法-BFS
- CSDN主办2017 OpenStack Days China将于7月在京召开!
- 拆分json数据,重组打包成新的json数组
- 平衡二叉树(AVL树)
- Android Studio Kotlin 开发环境配置
- 使用JAVA线程写的一个UDP简易通讯程序(三)
- 对泰坦尼克号案例进行数据挖掘
- python hashlib sha1和MD5哈希算法