我用这样的方法创建弹出对话框:
_PopUp=(item) => {
return (
<View>
<Dialog
height={100}
width={0.8}
visible={this.state.Visiable}
dialogAnimation={new ScaleAnimation({
initialValue: 0,
useNativeDriver: true,
})}
<DialogContent>
<Text>{item.Name} {item.Surname}</Text>
</DialogContent>
</Dialog>
</View>
)
}
,我在另一个方法中调用此函数:
_renderItems() {
return (
<View>
<FlatList
columnWrapperStyle={{ flex: 1, justifyContent: 'space-around' }}
data={this.props.workerListSigned}
numColumns={3}
keyExtractor={(workerListSigned) => workerListSigned.ID.toString()}
renderItem={({ item }) => {
return (
<TouchableOpacity onLongPress={() => this.setState({ Visiblee: true }, () => this._PopUp(item))}>
<View style={styles.flatListItemStyle}>
<Text style={{ textAlign: 'center' }}>{item.Name} {item.Surname}</Text>
<Text style={{ textAlign: 'center' }}>{item.Duty}</Text>
</View>
</TouchableOpacity>
)
}}
/>
</View>
)
}
İf我喜欢这样,不会出现弹出窗口。当我在渲染中使用“ this._PopUp”方法时,它将起作用。但是我需要在flatList中使用。我该怎么办?
render(){
return(
<View>
{this._PopUp()}
</View>
)
}