2017-08-13 28 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

相關問題