我是react native
的新手。我想在Android上使用Listview
测试refresh control
。当Listview
仅包含一行要渲染时,拉动刷新工作,但当要显示多于一行时,它不会调用刷新功能。我在网上看了各种各样的例子,但无法弄清楚下面代码有什么问题。
<ListView
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={this._onRefresh.bind(this)}
tintColor="#ff0000"
title="Loading..."
titleColor="#00ff00"
colors={['#ff0000', '#00ff00', '#0000ff']}
progressBackgroundColor="#ffff00" />
}
automaticallyAdjustContentInsets={false}
dataSource={this.state.dataSource}
renderRow={this.renderFeed.bind(this)}
renderHeader = {this.renderHeader.bind(this)}
renderSeparator={this.renderSeparator}
onEndReached={this.onEndReached.bind(this)}
scrollRenderAheadDistance={500}
onEndReachedThreshold={100}
/>
_onRefresh()
{
this.setState({refreshing: true});
console.log('refreshing....')
setTimeout(() => {
this.setState({
refreshing: false
});
}, 3000);
}
答案 0 :(得分:3)
在将contentContainerStyle设置为该视图
的视图中包装Listview<View contentContainerStyle={{flex: 1}}>
<ListView
//list view content here
/>
</View>
希望这有效