如何在本机中设置FlatList的刷新指示器?

Ahm*_*oor 9 android react-native react-native-flatlist

我正在尝试设置反应原生的平面列表的刷新指示器,但不知道如何做到这一点.List View有这个道具:

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

但是Flat List只有这些:

refreshing={this.props.loading}
onRefresh={this._onRefresh.bind(this)}
Run Code Online (Sandbox Code Playgroud)

Ahm*_*oor 18

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

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

  • 添加tintColor作为ios的道具。否则它的工作完美 (2认同)

小智 5

refreshControl={
          <RefreshControl
            isRefreshing={isRefreshing}
            onRefresh={loadProducts}
            colors={[Colors.GreenLight]} // for android
            tintColor={Colors.GreenLight} // for ios
          />
        }
Run Code Online (Sandbox Code Playgroud)

这涵盖了ios和android