react native listview可以放进scrollview里吗
2个回答
展开全部
答案是肯定可以的!
我想楼主的意思是想在一个组件上既显示一个ListView,还要显示一些其他的东西,比如图片,文本,具体代码参考如下:
import ReactNative from 'react-native';
import React, { Component } from 'react';
import styles from './styles';
const { View, Text, ScrollView, Image, ListView } = ReactNative;
class MyNewComponent extends Component {
constructor(props){
super(props);
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
dataSource: ds.cloneWithRows(['hello', '1ffasdf', 'fasdfasd', 'Peter', '8799ffff','faddsffasd', 'afdafsdf', 'fasdfasdf',' afsdfasdfasd', 'a', 'b', 'c', 'd']),
}
}
render() {
return (
<View style={styles.container}>
<ScrollView>
<ListView
dataSource={this.state.dataSource}
renderRow={(rowData) => <Text>{rowData}</Text>}
style={{height: 100,}}
/>
<Text>Hello World</Text>
<Image source={require("../../images/user2.jpg")} />
<Image source={require("../../images/user2.jpg")} />
</ScrollView>
</View>
);
}
}
export default MyNewComponent;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询