0
私はListviewにモーダルを実装しようとしていますが、各リストコンポーネントはクリック可能であり、関連情報を持つモーダルを表示します。私は現在、この仕事を得ることができません。ListViewのネイティブモーダルに反応します
でrenderRow機能:
var modalState = false;
open =() => {
modalState = true;
}
close =() => {
modalState = false;
}
return (
<View>
<View style={{flexDirection: 'row', padding: 3}}>
<Card
>
<CardItem>
<TouchableHighlight
style={{padding: 15}}
underlayColor = 'transparent'
onPress = {() => {
modalState = true;
alert(modalState);
}}
>
<Text style = {{color:'grey'}}>{devices.name}</Text>
</TouchableHighlight>
<TouchableHighlight
style={{padding: 15}}
underlayColor = 'transparent'
onPress = {() => {
modalState = true;
alert(modalState);
}}>
<View>
<Text> </Text>
</View>
</TouchableHighlight>
</CardItem>
</Card>
</View>
<Modal isVisible={modalState}>
<Card>
<CardItem>
<View style = {styles.modal}>
<Text>{devices.name}</Text>
<Button
title = "close"
onPress = {() => {
modalState = false;
}}
/>
</View>
</CardItem>
</Card>
</Modal>
</View>
);
Btwでは、ListViewが推奨されなくなりました。 [email protected]から、FlatList、SectionList、またはVirtualizedListに切り替える必要があります。 https://facebook.github.io/react-native/blog/2017/03/13/better-list-views.html –