react-native-simpledialog-android
React Native Android module to use Android's AlertDialog - same idea of AlertIOS
Installation
npm install react-native-simpledialog-android --save
Add it to your android project
- In
android/settings.gradle
...include ':RNSimpleAlertDialogModule', ':app'project(':RNSimpleAlertDialogModule').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-simpledialog-android/android')
- In
android/app/build.gradle
...dependencies { ... compile project(':RNSimpleAlertDialogModule')}
- Register Module >= 0.17 && <= 0.29(in
MainActivity.java
) - NOTE: >= RN 29 split
MainActivity.java
intoMainActivity.java
andMainApplication.java
. So make modifications below toMainApplication.java
// <--- import
Usage
This module are very similar to AlertIOS native module, and only works with alert method (prompt method aren't implemented yet).
The main difference are in the way that you declare buttons. In Android you can declare up to 3 buttons and in this module you have to declare what type the button is. A button can be SimpleAlert.POSITIVE_BUTTON, SimpleAlert.NEGATIVE_BUTTON or SimpleAlert.NEUTRAL_BUTTON.
Example
var SimpleAlert = ; { console;}; SimpleAlert;
License
MIT