Cell.js
Import from "React";
Import {
View,
StyleSheet,
Dimensions,
"react-native"
{height, width} = dimensions.get (' window ')
export default Component {
render () {
<style={style. Container}/>
);
}
style = StyleSheet. Create {
: {
: Ten,
"Red",
:
: (width-40)/2.0
},
});
Index.ios.js
ImportReact, {Component} from' react ';Import{appregistry, StyleSheet, Text, View, ListView,} from' react-native ';ImportCell from"./cell" Export Default classListviewcellextendsComponent {Constructor (props) {Super(props); LetDS =NewListview.DataSource({rowhaschanged: (r1, R2) => R1!==}); This. State= {DataSource: Ds.clonewithrows (["1","2","3","4"])
} This. _renderrow = This. _renderrow.bind ( This); } render () { return(<ListView DataSource={ This. State.DataSource}Renderrow={ This. _renderrow}Contentcontainerstyle={styles.Container}/>); } _renderrow (data) { return(<Cell/>); }
}ConstStyles = StyleSheet.Create({Container: {Flex: 1,flexdirection:"Row",Flexwrap:"Wrap",justifycontent:"Flex-start",BackgroundColor:' #F5FCFF ',
},
}); Appregistry.registercomponent (' Listviewcell ', () => Listviewcell);
The effect is as follows