2016-04-21 42 views
2

我还是新的反应本地的,上单击创建模态反应,原生的Android

那么我试过是做一个简单的应用程序, 有按钮,当按下它只是打开警报 作为本守则

class MyFirstReactapril extends Component{ 
    render(){ 
    return(
     <View style={styles.container}> 
     <Text style={styles.welcome}> Welcome Nesreen</Text> 
     <TouchableHighlight style={styles.button} onPress={this.showAlert}> 
     <Text style={styles.buttonText}>Myalert</Text> 
</TouchableHighlight> 
     </View> 
    ) 
    } 
    showAlert(){ 
Alert.alert('Fast Donation','', [{text : 'Donate now'},{text : 'add to Container'}]) 
    } 
} 

现在我想开模态上的按钮,点击不仅仅是警报 我试图读取该 http://facebook.github.io/react-native/docs/modal.html#content 但我真的失去了 我怎样才能使模态反应使用母语?

回答

0

你可以使用下面的模态。

<Modal visible={this.state.isModalOpen} 
     onRequestClose={() => this.setState({isModalOpen: false})} animationType={"slide"} 
     transparent={false}> 
     <View> 
         //Create your modal view inside this 
     </View> 
</Modal> 

在你showAlert()方法设置isModalOpen在您的状态为真。