【发布时间】:2015-10-21 11:33:55
【问题描述】:
有谁知道如何在 React-Native 中为 android 实现列表视图刷新器? 我认为这是很多人的普遍问题。
有react-native-refreshable-listview,但不支持android。
【问题讨论】:
-
根据您需要的紧急程度,我正在阅读它是 v0.16 中组件的高优先级/最爱
标签: android listview react-native
有谁知道如何在 React-Native 中为 android 实现列表视图刷新器? 我认为这是很多人的普遍问题。
有react-native-refreshable-listview,但不支持android。
【问题讨论】:
标签: android listview react-native
您应该能够通过使用随 React Native 0.16 启动的 PullToRefreshViewAndroid (https://facebook.github.io/react-native/docs/pulltorefreshviewandroid.html#content) 来完成此行为。
正如本期提到的:https://github.com/facebook/react-native/issues/4793,您可能必须在PullToRefreshView 上使用style={{flex: 1}} 才能达到您想要的结果,如下所示:
<PullToRefreshViewAndroid
refreshing={isRefreshing}
onRefresh={this.onRefresh}
style={{ flex: 1 }}>
<ListView
...listViewProps />
</PullToRefreshViewAndroid>
那么你应该得到与 ReactNativeRefreshableListView 相同的行为,但在 Android 上。
【讨论】:
React-native 有一个开箱即用的拉刷新解决方案
<ListView
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={this.onRefresh.bind(this)}
/>
}
...
dataSource={this.state.dataSource}
/>
在你班级的其他地方,一个 onRefresh() 函数......
onRefresh() {
this.setState({refreshing:true});
//refresh data and set refreshing to false as appropriate for your app...
}
【讨论】: