react-native(리액트 네이티브) component - ListView
import React, {Component} from 'react';
import {StyleSheet, View, Text, ListView, Dimensions, TouchableHighlight, Alert} from 'react-native';
const { height, width } = Dimensions.get("window");
export default class MyComponent extends Component {
constructor() {
super();
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
dataSource: ds.cloneWithRows(['row 1', 'row 2', 'row 3', 'row 4', 'row 5']),
};
}
_onPressLearnMore = () => {
Alert.alert('this function is not defined')
}
render() {
return (
<ListView
dataSource={this.state.dataSource}
renderRow={(rowData) =>
<TouchableHighlight
onPress={this._onPressLearnMore}
>
<Text>{rowData}</Text>
</TouchableHighlight>}
renderSeparator={(sectionId, rowId) =>
<View key={rowId} style={styles.separator} />
}
/>
);
}
}
const styles = StyleSheet.create({
separator: {
flex: 1,
height: StyleSheet.hairlineWidth*10,
width: width,
backgroundColor: 'red',
},
});
'프로그래밍(Programming) > 리액트 네이티브(React Native)' 카테고리의 다른 글
react-native(리액트 네이티브) component - Modal (0) | 2019.01.07 |
---|---|
react-native(리액트 네이티브) component - ListView_Grid (0) | 2019.01.06 |
react-native(리액트 네이티브) component - Image (0) | 2019.01.06 |
react-native(리액트 네이티브) component - FlatList_MultiColumn (0) | 2019.01.06 |
react-native(리액트 네이티브) component - FlatList (0) | 2019.01.06 |