Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react native picker is not showing in android

I am trying to add picker in react native android but it does not showing in android. I map my location date to picker item but i did'nt see picker in screen.

<Picker selectedValue={this.state.location}>
  <Picker.Item label="Location 1" value="1" /> 
  <Picker.Item label="Location 2" value="2" />
  <Picker.Item label="Location 3" value="3" />
</Picker>
like image 960
Anwar Hussain Avatar asked Mar 06 '16 18:03

Anwar Hussain


5 Answers

Are you giving it width and height? That was my problem

like image 140
Ahmad Moussa Avatar answered Nov 01 '22 14:11

Ahmad Moussa


picker doesn't appear on screen if it doesn't have style with height,weight or flex property

<Picker

  style={{flex:1}} >
  <Picker.Item label="Location 1" value="1" /> 
  <Picker.Item label="Location 2" value="2" />
  <Picker.Item label="Location 3" value="3" />

</Picker>
like image 36
Dulanga Heshan Avatar answered Nov 01 '22 14:11

Dulanga Heshan


For me, it was a "alignItems: 'center'," on the parent view component.

I would comment out all/each style of your styles.container

like image 25
William Choy Avatar answered Nov 01 '22 15:11

William Choy


Worked for me too by assigning a width to the Picker specifically.

like image 42
Van I Avatar answered Nov 01 '22 15:11

Van I


You need to set your onValueChange method

I am trying to add picker in react native android but it does not showing in android. I map my location date to picker item but i did'nt see picker in screen.

<Picker
    style={{width: 100}} 
    selectedValue={this.state.location}
    onValueChange={(loc) => this.setState({location: loc})}>
  <Picker.Item label="Location 1" value="1" /> 
  <Picker.Item label="Location 2" value="2" />
  <Picker.Item label="Location 3" value="3" />
</Picker>
like image 44
Chris Geirman Avatar answered Nov 01 '22 15:11

Chris Geirman