React-Native刷新Flatlist不适用于Android

时间:2018-06-19 04:00:31

标签: react-native

当用户按下由gpsDataSource

填充的平面列表时
this.state = {
  gpsDataSource: [
    { selected: false, title: I18n.t('Settings_precise_11f271'), code: 'precise' },
    { selected: false, title: I18n.t('Settings_approximate_b23bbf'), code: 'approximate' },
    { selected: true, title: I18n.t('Settings_off_810357'), code: 'off' },
  ],
};

填充

        <FlatList
          data={this.state.gpsDataSource}
          extraData={this.state.refresh}
          renderItem={({ item, index }) =>
          <View>
              {(Platform.OS === 'android') ? 
              <TouchableNativeFeedback onPress={() => this._onGPSPress(item)}  background={TouchableNativeFeedback.SelectableBackground()} >
                  <View>
                    <MenuItem
                      item={item}
                      navigation={this.props.navigation}
                    />
                  </View>
                  </TouchableNativeFeedback>
                  :
                  <TouchableHighlight
                      onPress={() => this._onGPSPress(item)} 
                      underlayColor='gray'>
                      <MenuItem
                          item={item}
                          onPress={() => this._onGPSPress(item)} 
                          navigation={this.props.navigation}

                          />

                  </TouchableHighlight>
              }
          </View>
      }

          keyExtractor={(item, index) => index.toString()}
        />

用户选择一个项目

 _onGPSPress(_click) {
    this.state.gpsDataSource.map(element => {
      if (element.code == _click.code) 
      {console.log("match");  element.selected = true; return element }
      else { console.log("no match");element.selected = false ; return element }
    });
this.setState({
  refresh: !this.state.refresh
})

//Todo: appropriate server calls
  }

平板列表在iOS上刷新但不是Android(顺便说一句,Menuitem在两个平台上都是相同的。

如何获取针对Android刷新的平面列表(菜单项中选定的蓝点)?

0 个答案:

没有答案