如何通过此代码创建搜索列表:
onPress={() =>this.props.navigation.navigate('LinhaDiurno03')
何时按下项目?
...。我希望列表中的每个项目在应用程序中打开一个不同的屏幕。...
我该怎么办?
这是我的睾丸:
此处是一些代码:
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
答案 0 :(得分:1)
我阅读了库API,您可以在项目中设置导航键,然后在onItemSelect
中进入特殊屏幕。示例代码如下。
// 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)
}}
/>
答案 1 :(得分:0)
这是最终代码,您只需要在应用中进行以下操作即可... the full code