我有我想要的flatlist使其迭代,并显示多次作为一个列表来呈现两个按钮。我应该怎么办呢?
<FlatList
data={this.state.data}
extraData={this.state}
renderItem={this.renderItem}
keyExtractor={items => items.id}
/>
<TouchableOpacity onPress={this.onPressButtonPlay.bind(this)}>
<Text style={styles.buttonText}> </Text>
</TouchableOpacity>
<TouchableOpacity onPress={this.onPressButtonPause.bind(this)}>
<Text style={styles.buttonText}>{this.state.pause ? 'Resume' : 'Pause'}</Text>
</TouchableOpacity>
只需在您的renderItem函数中插入:
renderItem = ({item}) => {
return(
<TouchableWithoutFeedback>
<TouchableOpacity>
{this.renderButton()}
</TouchableOpacity>
<TouchableWithoutFeedback>
);
}