/**? Sample React Native App?
* https://github.com/facebook/react-native?
* @flow? */
"use strict"
import React, {Component} from 'react'
import {
AppRegistry,
View,
Text,
Picker,
StyleSheet
} from 'react-native'
var PickerData = [
'11',
'22',
'33',
'44',
'55',
'66'
]
class HelloWorld extends Component {
constructor(props) {
super(props)
this.state={
firstPickerValue: '1',
secondPickerValue: PickerData[0],
}
}
updateFirstContent(language) {
this.setState({
firstPickerValue: language,
})
}
updateSecondContent(language) {
this.setState({
secondPickerValue: language,
})
}
/* 必须有这个 key , 详细请参考 scrollview 博文
* 也可以 此段代码直接放在Picker组件内,
* 这样就是一条一条的添加,不是通过已知数组循环添加
* */
renderPicker(key, i) {
// console.log(key , i)
return
}
render() {
return (
{this.state.firstPickerValue}
selectedValue={this.state.firstPickerValue}
onValueChange={(language) => this.updateFirstContent(language)}>
{this.state.secondPickerValue}
onValueChange={(language) => this.updateSecondContent(language)}>
{PickerData.map((key, i) => this.renderPicker(key, i))}
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF'
},
text: {
width: 200,?
height: 60,
backgroundColor: 'white',?
justifyContent:'center',?
alignItems: 'center',?
borderRadius: 5,
},
picker:{
padding: 50
}
})
AppRegistry.registerComponent('HelloWorld', () => HelloWorld);