2017-08-13 25 views
3

我试图设置反应本地的平板列表刷新指标,但不知道如何去做。列表视图有这个道具:如何设置FlatList的刷新指标为反应本机?

refreshControl={<RefreshControl 
         colors={["#9Bd35A", "#689F38"]} 
         refreshing={this.props.refreshing} 
         onRefresh={this._onRefresh.bind(this)} 
        /> 
       } 

但平直列表只有这些:

refreshing={this.props.loading} 
onRefresh={this._onRefresh.bind(this)} 
+0

这个链接的作品的解决方案,请选中该[链接](https://stackoverflow.com/questions/38256972/how-to-customize-look-feel-of-react-native -listviews-refreshcontrol)。 – bamne123

回答

4

我找到了解决办法!它可能是虚拟的,但FlatList也有一个名为refreshControl的道具,像ListView,但我没有测试它!就像这样:

refreshControl={ 
    <RefreshControl 
     colors={["#9Bd35A", "#689F38"]} 
     refreshing={this.props.refreshing} 
     onRefresh={this._onRefresh.bind(this)} 
    /> 
} 
+0

我现在也在使用这个解决方案,它可以工作,但我担心它不是正确的方法。我将来再研究并更新你。如果你还发现,请更新。 – Noitidart

1

您可以在renderScrollComponent传递到您的FlatList组件与你在上面显示了同样的RefreshControl组件。我创建了一个世博会的小吃此:https://snack.expo.io/rJ7a6BCvW

的FlatList是内本身使用VirtualizedList,并VirtualizedList组件,它需要一个renderScrollComponenthttps://facebook.github.io/react-native/docs/virtualizedlist.html#renderscrollcomponent

+1

我试过了,但没有奏效!对象不是一个函数(评估'this.props.renderScrollComponent(this.props)') –

+0

我也试过这个。我不确定它是否正确,因为它似乎改变了整个滚动组件。不只是刷新控制。我将来会研究更多,如果你做出任何发现或者对renderScrollComponent方法非常肯定,请做更新。 – Noitidart

相关问题