Skip to content
This repository has been archived by the owner on Dec 23, 2018. It is now read-only.

Android Spinner (Dropdown) component for React Native

License

Notifications You must be signed in to change notification settings

webschik/react-native-spinner-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-spinner-android

Android Spinner component for React Native

!!! Deprecated !!!

This module is deprecated now. Use React-Native Picker instead.

Installation Android

  • npm install --save react-native-spinner-android
  • In android/setting.gradle
include ':ReactNativeSpinnerAndroid', ':app'
project(':ReactNativeSpinnerAndroid').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-spinner-android/android')
  • In android/app/build.gradle
...
dependencies {
    ...
    compile project(':ReactNativeSpinnerAndroid')
}
  • register module (in MainActivity.java)
import com.webschik.reactnativespinnerandroid.SpinnerPackage; // import

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
  ......

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReactRootView = new ReactRootView(this);

    mReactInstanceManager = ReactInstanceManager.builder()
      .setApplication(getApplication())
      .setBundleAssetName("index.android.bundle")
      .setJSMainModuleName("index.android")
      .addPackage(new MainReactPackage())
      .addPackage(new SpinnerPackage())              // add here
      .setUseDeveloperSupport(BuildConfig.DEBUG)
      .setInitialLifecycleState(LifecycleState.RESUMED)
      .build();

    mReactRootView.startReactApplication(mReactInstanceManager, "ExampleRN", null);

    setContentView(mReactRootView);
  }
  ......
}

Usage

import Spinner from 'react-native-spinner-android';

...

  render() {
    return (
      <Spinner values={['--Choose--', '1', 2, 3.5]} 
               selected={1} 
               onChange={(data) => { console.log(data); }} />
    );
  }
  

Props

onChange(data)

Callback with data in the form data = { selected: 1, value: '1' }

About

Android Spinner (Dropdown) component for React Native

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published