Nativebase: Andoid placeholder not work

Created on 20 Jul 2018  Â·  11Comments  Â·  Source: GeekyAnts/NativeBase

  • node - v8.9.4
  • npm - v5.6.0
  • react-native - 0.53.0
  • react - v16.2.0
  • native-base - v2.4.5

Expect

Show placeholder on Android, iOS works well

Result

Show first Picker.Item element

I changed to default <Picker.Item label={label]} value={null}/> and show this now, but I need remove that item for current work

awaiting response

Most helpful comment

It's already 2019, and Picker still not supporting placeholder in Android.

All 11 comments

@ihusak Android Picker does not support placeholder, documented

I changed to default and show this now, but I need remove that item for current work

I did not get this, can you be more clear

@SupriyaKalghatgi I added <Picker.Item label={label]} value={null}/> and it's added me another item to my checklist, but user can choose it and send value null, I write some function to prevent errors. But placeholder will be perfect solve for this task

@ihusak I have stated above that

Android Picker does not support placeholder, documented

I created my own Picker Component (abstracting away the Native Base Picker) which has an option to display a Placeholder both for Android and iOS by inserting a 'Please select …' option to the options array. Upon selection of a Picker Item, this additional 'Please select …' options gets removed.

Quite simple really.

I think this same approach could be used by Native Base itself to get feature parity regarding the Picker Placeholder between iOS and Android.

It's already 2019, and Picker still not supporting placeholder in Android.

It's already 2019, and Picker still not supporting placeholder in Android.

You can do like this:

//return each items after mapping over the list items
const selectionItems = props.selectionList.map((item, index) => {
return ;
})
// this is the important part. put the placeholder value in the array by appending the value at the beginning of the array. Since placeholder prop is not selected in Android.
selectionItems.unshift()
mode="dropdown"
placeholder={props.placeholder}
>
{selectionItems}

It's already 2020, and Picker still not supporting placeholder in Android.

It's already 2020, and Picker still not supporting placeholder in Android.

Picker doesn't show placeHolder value in Android.
mode="dropdown"
iosIcon={}
style={{
color: '#174A7A',
fontSize: 20
}}
placeholder="Select your Country*"
placeholderStyle={{ color: "#bfc6ea", fontSize: 20 }}
selectedValue={this.state.selected}
onValueChange={this.onValueChange.bind(this)}>

Picker placeholder doesn't work in Android.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

muthuraman007 picture muthuraman007  Â·  3Comments

agersoncgps picture agersoncgps  Â·  3Comments

Bundas picture Bundas  Â·  3Comments

inv2004 picture inv2004  Â·  3Comments

bsiddiqui picture bsiddiqui  Â·  3Comments