简体   繁体   中英

React native ListView is not scrolling

I'm writing an app using react native. It has a ListView to show the list of items. My code looks like this:

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){
}


});

That's work perfectly the list scrolls. But if I had a ToolbarAndroid like this:

    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>
    );

The ListView is not scrolling. What I have forgotten?

My style:

toolbar: {
    backgroundColor: '#e9eaed',
    height: 56
}


listView: {
    flexDirection: 'column',
    flex:1,
    backgroundColor: '#F5FCFF'
}

I have tried to add container View and ScrollView but that's not work too.

you should add a style to like :

<View style={styles.container}>
   <ToolbarAndroid />
   <ListView />
</View>

style:

container:{
flex:1,
}

i dont know why,but it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM