猿问

react native listview可以放进scrollview里吗

繁花不似锦
浏览 971回答 1
1回答

婷婷同学_

答案是肯定可以的!我想楼主的意思是想在一个组件上既显示一个ListView,还要显示一些其他的东西,比如图片,文本,具体代码参考如下:123456789101112131415161718192021222324252627282930import ReactNative from 'react-native';import React, { Component } from 'react';import styles from './styles';const { View, Text, ScrollView, Image, ListView } = ReactNative;class MyNewComponent extends Component {&nbsp; constructor(props){&nbsp; &nbsp; super(props);&nbsp; &nbsp; const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});&nbsp; &nbsp; this.state = {&nbsp; &nbsp; &nbsp; dataSource: ds.cloneWithRows(['hello', '1ffasdf', 'fasdfasd', 'Peter', '8799ffff','faddsffasd', 'afdafsdf', 'fasdfasdf',' afsdfasdfasd', 'a', 'b', 'c', 'd']),&nbsp; &nbsp; }&nbsp; }&nbsp; render() {&nbsp; &nbsp; return (&nbsp; &nbsp; &nbsp; <View style={styles.container}>&nbsp; &nbsp; &nbsp; &nbsp; <ScrollView>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <ListView&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataSource={this.state.dataSource}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; renderRow={(rowData) => <Text>{rowData}</Text>}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; style={{height: 100,}}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Text>Hello World</Text>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Image&nbsp; source={require("../../images/user2.jpg")} />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Image&nbsp; source={require("../../images/user2.jpg")} />&nbsp; &nbsp; &nbsp; &nbsp; </ScrollView>&nbsp; &nbsp; &nbsp; </View>&nbsp; &nbsp; );&nbsp; }}export default MyNewComponent;

慕姐8265434

存在问题呢?在真机上上拉加载和下拉的时候都会出现一些难以预计的问题
随时随地看视频慕课网APP
我要回答