react-native-modal-picker
react-native-modal-picker copied to clipboard
Not working on Android 5.0
not working on Android 5.0 with react native > 29
I have the same problem. using
<ModalPicker data={data} initValue="Select something yummy!" onChange={(option)=>{ this.setState({textInputValue:option.label})}}>
<TextInput style={{borderWidth:1, borderColor:'#ccc', padding:10, height:30}} editable={false} placeholder="Select something yummy!" value={this.state.textInputValue} />
but I solve it to delete TextInput , In Ios the sample it's work. In Android I guess the TextInput mask the origin onPress event.
ps. sorry I don't know why the editor will eat my <ModalPicker
If you really need to use this TextInput you can resolve this problem by wrapping ModalPicker and TextInput in one container as siblings, and give them absolute position to the containe, with proper opacity and zIndex:
<View style={modalStyles.selectModalContainer}>
<ModalPicker
data={data}
style={modalStyles.selectModalComponent}
initValue="Select something yummy!"
onChange={(option)=>{ this.setState({textInputValue:option.label})}}
/>
<TextInput
style={modalStyles.inputStyleSelectModal}
editable={false}
placeholder="Select something yummy!"
value={this.state.textInputValue}
/>
</View>
const modalStyles = StyleSheet.create({
selectModalContainer: {
position: 'relative',
width: 200,
height: 30,
},
selectModalComponent: {
position: 'absolute',
opacity: 0,
width: 200,
zIndex: 2,
},
inputStyleSelectModal: {
position: 'absolute',
textAlign: 'right',
width: 200,
height: 30,
zIndex: 1
}
});