如何在本机反应中创建可搜索的下拉列表以打开特定屏幕?

我正在尝试使用列表,下拉列表,

如何在本机反应中创建可搜索的下拉列表以打开特定屏幕?

如何在本机反应中创建可搜索的下拉列表以打开特定屏幕?

如何通过此代码创建搜索列表:

 onPress={() =>this.props.navigation.navigate('LinhaDiurno03')

何时按下项目?

...。我希望列表中的每个项目在应用程序中打开一个不同的屏幕。...

我该怎么办?

这是我的睾丸:

Code to dropDown List

此处是一些代码:

 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',{id: 3,name: 'VILA SECA',];

 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
steven35 回答:如何在本机反应中创建可搜索的下拉列表以打开特定屏幕?

我阅读了库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)
            }}
/>
,

这是最终代码,您只需要在应用中进行以下操作即可... the full code

本文链接:https://www.f2er.com/3136277.html

大家都在问