Skip to content

Android platform to use the correct method

佘小恒 edited this page Dec 29, 2016 · 4 revisions

Step 1

$ git clone https://github.com/beefe/react-native-picker.git
  • Correct screenshot
1

Step 2

$ cd react-native-picker/example/PickerTest/android
  • Correct screenshot
2

Step 3

$ npm install
  • Correct screenshot
3

Step 4

$ react-native link react-native-picker

and

$ react-native run-android
  • Correct screenshot
4

Be sure to be there:

rnpm-install info Android module react-native-picker is already linked
rnpm-install info iOS module react-native-picker is already linked

The corresponding changes in the file :

  • android/settings.gradle
include ':react-native-picker'
project(':react-native-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-picker/android')
  • android/app/build.gradle
compile project(':react-native-picker')
  • android/src/main/java/com.xx/MainApplication.java
import com.beefe.picker.PickerViewPackage;

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                new MainReactPackage(),
                new PickerViewPackage()          // Added there
            );
        }
    };

Running screenshots

5

Version Info

  • react-native-picker: github:beefe/react-native-picker(current: v4.0.14)
  • react-native: v0.32.0
Clone this wiki locally