【发布时间】:2019-04-22 04:55:14
【问题描述】:
我是新来的反应原生我正在研究 AutoCompleteTextView 。我有一个 json 文件,我需要在自动完成视图中显示国家名称。我已经显示了所有国家的国名。但是在选择国家时它没有选择。我正在显示的 json 文件 is.
我的自动完成代码是。
render() {
const { query } = this.state;
return (
<KeyboardAwareScrollView
innerRef={ref => this.scrollView = ref} //... Access the ref for any other functions here
contentContainerStyle={{flex: 1}}>
<View>
<View style={styles.autocompleteContainer}>
<Autocomplete
data={timezones}
defaultValue={query}
autoCapitalize="none"
autoCorrect={false}
onChangeText={text => this.setState({ query: text })}
placeholder="Enter Country"
renderItem={({ name, latlng }) => {
const prodNames = latlng.map(item => item.prodNames);
<TouchableOpacity onPress={() => this.setState({ query: text })}>
<Text>{name} {prodNames}</Text >
</TouchableOpacity>
}}
/>
</View>
<View>
<Text>Some content</Text>
</View>
【问题讨论】:
标签: json react-native npm autocompletetextview