用户需要在
演示:https://snack.expo.io/ByJ_yWehM
组件的目的是在用户在
FlatList
项目上点击两次,因为<TextInput
的autoFocus={true}
。第一次点击时键盘会隐藏,下一次点击会调用onPress={this.GetItem.bind(this, item)}
。是否有任何选项可以在第一次点击时调用GetItem()
而不是点击两次。演示:https://snack.expo.io/ByJ_yWehM
export default class App extends Component {
GetItem (item) {
console.log(item);
Alert.alert(item);
}
render() {
return (
<View style={styles.container}>
<TextInput
autoFocus={true}
style={styles.paragraph}
keyboardType='web-search'
>
Change code in the editor and watch it change on your phone!
Save to get a shareable url.
</TextInput>
<Card title="Local Modules">
<View>
<TextInput
style={styles.searchField}
placeholder="Type here to translate!"
onChangeText={(text) => this.setState({text})}
/>
<FlatList
data={["akin","alike","close","comparable","like","similar","uniform","Allied","Analogous","Co-ordinate","Commensurate","akin","alike","close","comparable","like","similar","uniform","Allied","Analogous","Co-ordinate","Commensurate"]}
renderItem={({item}) => (
<Text
style={styles.listField}
onPress={this.GetItem.bind(this, item)}
>{item}</Text>
)}
/>
</View>
</Card>
</View>
);
}
}
组件的目的是在用户在
<TextInput>
中搜索时,在<FlatList>
中提供自动建议。
<TextInput>
中搜索时,在<FlatList>
中提供自动建议。 - Mo.