如果需要分组/类/区(section),请使用
使用方便简单,如下:
import React, { Component } from 'react'
import {
View,
Image,
Dimensions,
ScrollView,
Text,
StyleSheet,
TouchableOpacity,
Button,
FlatList,
ActivityIndicator,
RefreshControl,
}from 'react-native'
var flatListData = [{
key: 'a',
text: '444'
},{
key: 'b',
text: '333'
},{
key: 'c',
text: '2222'
},{
key: 'd',
text: '111'
}];
class DetailePageextends Component {
constructor(props) {
super(props);
this.state = {
};
}
render() {
const { params } = this.props.navigation.state;
return (
data={flatListData}
ListHeaderComponent={this.ListHeaderComponent.bind(this)}
renderItem={this.renderItem.bind(this)}
keyExtractor={this._keyExtractor}
refreshControl={
false}
/>
}
/>
)
}
//此函数用于为给定的item生成一个不重复的key
_keyExtractor = (item, index) => item.key;
componentDidMount() {
}
//列表的头部
ListHeaderComponent() {
return (
'学习' unitName='111'/>
)
}
//列表的每一行
renderItem({item,index}) {
return (
1} onPress={this.clickItem.bind(this,item,index)}>
)
}
//绘制列表的分割线
renderItemSeparator(){
}
//点击列表点击每一行
clickItem(item,index) {
alert(index)
}
}
export default DetailePage