前端之家收集整理的这篇文章主要介绍了
React-Native ListView简单使用,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
/** * Created by Administrator on 2016/8/30. */
import React,{Component} from 'react';
import {
AppRegistry,StyleSheet,Text,View,ListView,} from 'react-native';
class ListViewG extends Component {
/** * 初始化数据 * @param props */
constructor(props) {
super(props);
var ds = new ListView.DataSource({rowHasChanged: ((r1,r2) => r1 !== r2)});
this.state = {
dataSource: ds.cloneWithRows([
'Android','IOS','React-Native','H5','JAVA','OC','Go','Swift','C','C++','C#','Python','PHP'
])
}
}
render() {
return (
<View style={{paddingTop: 20,flex: 1}}>
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderRow}
/>
</View>
)
}
/** * * @param rowData 数据源 * @param sectionID 组ID * @param rowID 行ID * @returns {XML} */
renderRow(rowData,sectionID,rowID) {
return (
<Text style={styles.row}>测试数据{rowData + '\n组ID' + sectionID + '\n行ID' + rowID}
</Text>
)
}
}
const styles = StyleSheet.create({
row: {
height: 80,fontSize: 20,
overflow: 'hidden'
}
});
module.exports = ListViewG;
原文链接:https://www.f2er.com/react/306098.html