【问题标题】:Autocomplete text not coming on top while selecting the data选择数据时自动完成文本未出现在顶部
【发布时间】: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


    【解决方案1】:

    你遇到错误了吗?

    尝试替换这个:

    <TouchableOpacity onPress={() => this.setState({ query: text })}>
    

    通过这个:

    <TouchableOpacity onPress={() => this.setState({ query: name+''+prodNames })}>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-07
      • 1970-01-01
      • 2018-11-03
      • 1970-01-01
      • 2015-11-17
      • 1970-01-01
      • 2020-05-22
      • 1970-01-01
      相关资源
      最近更新 更多