一、代码

 import React, { Component } from 'react';
import {
AppRegistry,
View,
Text,
SectionList,
} from 'react-native'; export default class App extends React.Component { constructor(props) {
super(props);
} _renderItem = (info) => {
var txt = ' ' + info.item.title;
return <Text
style={{ height: 60, textAlignVertical: 'center', backgroundColor: "#ffffff", color: '#5C5C5C', fontSize: 15 }}>{txt}</Text>
} _sectionComp = (info) => {
var txt = info.section.key;
return <Text
style={{ height: 50, textAlign: 'center', textAlignVertical: 'center', backgroundColor: '#9CEBBC', color: 'white', fontSize: 30 }}>{txt}</Text>
} render() {
var sections = [
{ key: "A", data: [{ title: "爱" }, { title: "啊" }, { title: "奥" }] },
{ key: "B", data: [{ title: "不" }, { title: "吧" }, { title: "包" }] },
{ key: "C", data: [{ title: "吃" }, { title: "车" }] },
{ key: "W", data: [{ title: "王者" }, { title: "王者荣耀" }] },
]; return (
<View style={{ flex: 1 }}>
<SectionList
numColumns ={3}
horizontal={false}
renderSectionHeader={this._sectionComp}
renderItem={this._renderItem}
sections={sections}
ItemSeparatorComponent={() => <View><Text></Text></View>}
ListHeaderComponent={() => <View style={{ backgroundColor: '#25B960', alignItems: 'center', height: 30 }}><Text style={{ fontSize: 18, color: '#ffffff' }}>通讯录</Text></View>}
ListFooterComponent={() => <View style={{ backgroundColor: '#25B960', alignItems: 'center', height: 30 }}><Text style={{ fontSize: 18, color: '#ffffff' }}>通讯录尾部</Text></View>}
/>
</View>
);
} }

二、效果图

React native 中 SectionList用法的更多相关文章

  1. [转] 「指尖上的魔法」 - 谈谈 React Native 中的手势

    http://gold.xitu.io/entry/55fa202960b28497519db23f React-Native是一款由Facebook开发并开源的框架,主要卖点是使用JavaScrip ...

  2. [转] 在React Native中使用ART

    http://bbs.reactnative.cn/topic/306/%E5%9C%A8react-native%E4%B8%AD%E4%BD%BF%E7%94%A8art 前半个月捣腾了一下Rea ...

  3. React Native 中 CSS 的使用

    首先声明,此文原作者为黎 跃春 React Native中CSS 内联样式 对象样式 使用Stylesheet.Create 样式拼接 导出样式对象 下面的代码是index.ios.js中的代码: / ...

  4. react native中的欢迎页(解决首加载白屏)

    参照网页: http://blog.csdn.net/fengyuzhengfan/article/details/52712829 首先是在原生中写一些方法,然后通过react native中js去 ...

  5. React Native中的网络请求fetch和简单封装

    React Native中的网络请求fetch使用方法最为简单,但却可以实现大多数的网络请求,需要了解更多的可以访问: https://segmentfault.com/a/1190000003810 ...

  6. react native中使用echarts

    开发平台:mac pro node版本:v8.11.2 npm版本:6.4.1 react-native版本:0.57.8 native-echarts版本:^0.5.0 目标平台:android端收 ...

  7. react native中一次错误排查 Error:Error: Duplicate resources

    最近一直在使用react native中,遇到了很多的坑,同时也学习到了一些移动端的开发经验. 今天在做一个打包的测试时,遇到了一个问题,打包过程中报错“Error:Error: Duplicate ...

  8. 在React Native中,使用fetch网络请求 实现get 和 post

    //在React Native中,使用fetch实现网络请求 /* fetch 是一个封装程度更高的网络API, 使用了Promise * Promise 是异步编程的一种解决方案 * Promise ...

  9. 《React Native 精解与实战》书籍连载「React Native 中的生命周期」

    此文是我的出版书籍<React Native 精解与实战>连载分享,此书由机械工业出版社出版,书中详解了 React Native 框架底层原理.React Native 组件布局.组件与 ...

随机推荐

  1. sql语句学习及索引学习,未完待续,补充增删改查

    1,查询出last_name 为 'Chen' 的 manager 的信息.  select * fromwhere employee_id = ( selectfrom employees wher ...

  2. list<实体类>互相嵌套和前台取值问题

    list<实体类>嵌套list<实体类>,必须保证嵌套的实体类里面有这个list对象,把这个list<实体类>当做一个对象 这是需要解析的数据,并把这些数据封装成l ...

  3. Jenkins结合shell脚本实现(gitLab/gitHub)前端项目自动打包部署服务器

    原始发布部署: 石器时代的我们,先是本地打包好项目,在去服务器上把原来的文件删了,然后回到本地copy到服务器: 这操看起来简单,实际部署的人就知道多烦了,假如来几个项目都要重新发布:那就爽了: 今天 ...

  4. WinForm界面设计优化过程

    以在做的项目为例,记录一下界面美化过程中遇到的问题,由于项目是先做出来之后,又请美工进行稍微调整设计界面,所以会又些限制 1. TabControl的问题----在添加了背景图片后,TabContro ...

  5. 磁盘当前目录下存在文件 c1.txt,其中存放了一段英文文字。请编程实现将c1.txt中英文文字全部转换为答谢字母,并保存到c2.txt中。要求:c2.txt文件前面保存的是c1.txt文案中的原始文字,后面紧跟着的是转换后的文字

    #include"stdio.h"#include"string.h" void main(){ FILE *fp1,*fp2; char ch[1000]=& ...

  6. samba及其基本应用

    Samba 137/udp,138/udp,139/tcp,445/tcp windowns主机共享: linux主机进行访问查看资源:smbclient -L Server_IP -U 用户名 li ...

  7. 10、Typescript-类的基本用法

    类就是构造函数的另一写法 以前构造函数的写法: 类的基本用法:

  8. Daily record-November

    November 11. I managed to grab her hand. 我抓到了她的手.2. He passed a hand wearily over his eyes. 他疲倦地用手抹了 ...

  9. 算法和数据结构~各位排序算法的介绍与实现(C#)

    排序是指将元素集合按照规定的顺序排列.通常有两种排序方法,升序排列和降序排列.例如,对整数集{5,2,7,1}进行升序排列,结果为{1,2,5,7},对其进行降序排列结果为{7,5,2,1}.总的来说 ...

  10. python之路-----MySql操作二

    一.主键 1.每个 表只有一个主键 2.每个主键可以由多个列组成.(如果主键由多个组成,只要有一行列值不等即可) CREATE TABLE NAME ( id INT auto_increment, ...