'react-native-elements'의 ListItem을 사용하고 있으며 긴 제품 목록이 있습니다.
<View style={{flex: 1}}>
{
this.state.displayArray.map((item, i) => (
<ListItem key={i}
bottomDivider
style={styles.listWidth}
onPress={() => this.props.navigation.navigate('ProductDetails', {productId:
parseInt(item.id)})}>
<Icon name='shopping-cart' />
<ListItem.Title style={styles.listTitle}>{item.name}</ListItem.Title>
<ListItem.Subtitle style={{ color: '#F78400'}}>{i18n.t("information.cost")}:
{item.cost}</ListItem.Subtitle>
</ListItem>
))
}
</View>
배경색 (예 : 흰색, 회색, 흰색, 회색, 흰색, ....)을 번갈아 가독성을 향상시킬 수있는 아이디어가 있는지 알고 싶습니다. 아마 재미 :))
간단한 모드 로직을 사용하여 대체 색상에 대한 짝수 행을 결정합니다.
짝수 % 2는 항상 0을 반환하고, 홀수 % 2는 항상 1을 반환합니다.이 논리를 사용하여 (i % 2 == 0)? 짝수 행 : 홀수 행
<View style={{flex: 1}}>
{
this.state.displayArray.map((item, i) => (
<ListItem key={i}
bottomDivider
//check mod for even odd rows and assign color
style={{backgroundColor: i % 2 === 0 ? '#000' : '#ccc' }
onPress={() => this.props.navigation.navigate('ProductDetails', {productId:
parseInt(item.id)})}>
<Icon name='shopping-cart' />
<ListItem.Title style={styles.listTitle}>{item.name}</ListItem.Title>
<ListItem.Subtitle style={{ color: '#F78400'}}>{i18n.t("information.cost")}:
{item.cost}</ListItem.Subtitle>
</ListItem>
))
}
</View>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다