【发布时间】:2016-02-29 14:59:31
【问题描述】:
我正在使用 react native 编写应用程序。它有一个 ListView 来显示项目列表。我的代码如下所示:
var ListMoviesView = React.createClass({
getInitialState() {
return {
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2
}),
loaded: false
};
},
componentDidMount : function() {
this.fetchData();
},
render : function() {
if (!this.state.loaded) {
return this.renderLoadingView();
}
return(
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderMovie}
style={styleList.listView} />
);
},
renderMovie(movie) {
return (
<View style={styleList.container}>
<Image source={{uri: movie.posters.thumbnail}} style={styleList.thumbnail} />
</View>
);
},
buttonClicked : function (movie){
}
});
列表滚动效果很好。但如果我有一个这样的 ToolbarAndroid:
return(
<View>
<ToolbarAndroid
actions={toolbarActions}
onIconClicked={() => this.setState({actionText: 'Icon clicked'})}
style={styleToolbar.toolbar}
subtitle={this.state.actionText}
title="Toolbar" />
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderMovie}
style={styleList.listView} />
</View>
);
ListView 没有滚动。我忘记了什么?
我的风格:
toolbar: {
backgroundColor: '#e9eaed',
height: 56
}
listView: {
flexDirection: 'column',
flex:1,
backgroundColor: '#F5FCFF'
}
我尝试添加容器 View 和 ScrollView,但这也不起作用。
【问题讨论】:
标签: listview react-native