如何在本机反应中创建可搜索的下拉列表以打开特定屏幕? [英] How to make a searchable droplist in react native to open an specific screen?
本文介绍了如何在本机反应中创建可搜索的下拉列表以打开特定屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用列表,下拉列表,
创建搜索栏
I'm trying to make a search bar with a list,dropdown list,
如何通过以下代码创建搜索列表:
how to make a search list lik this code:
onPress={() =>this.props.navigation.navigate('LinhaDiurno03')
何时按下项目?
....我希望列表中的每个项目在应用程序中打开一个不同的屏幕....
....I want that each item in the list open a different screen in the application....
我该怎么办?
这是我的遗嘱:
此处为某些代码:
var items = [
//name key is must.It is to show the text in front
{id: 1, name: 'ANA RECH', prestadora: 'UNIDOS', pos: 'P01'},
{id: 2, name: 'ARROIO DAS MARRECAS', prestadora: 'UNIDOS', pos: 'P01'},
{id: 3, name: 'VILA SECA', prestadora: 'UNIDOS', pos: 'P01'},];
onItemSelect={item => Alert.alert(" ", JSON.stringify(item.prestadora + ", LINHA: " + item.pos), [{ text: "open the especifc screen", onPress: () =>('some code here')},{ text: "bacvk", onPress: () => console.log("OK Pressed")}],{ cancelable: true })}
//onItemSelect called after the selection from the dropdown
推荐答案
我阅读了库API,可以设置导航键,然后在 onItemSelect
中转到特殊屏幕。
I read the library API, you can set the navigation keys in the item, then in the onItemSelect
to go to the special screen. the example code is below.
// in the item every element add a router key
const item = [
...
{
id: 8,
name: 'Swift',
key:"the navigation params" //like the example LinhaDiurno03
},
...
]
<SearchableDropdown
multi={true}
selectedItems={this.state.selectedItems}
onItemSelect={(item) => {
his.props.navigation.navigate(item.key)
}}
/>
这篇关于如何在本机反应中创建可搜索的下拉列表以打开特定屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文