React-Native基础_5.列表视图ListView
列表视图ListView
用来显示垂直滚动列表,需要指定两个东西,1 数据的来源 dataSource,2 渲染列表的条目布局 rendRow
'use strict'
import React, {Component} from 'react';
import {
AppRegistry,
StyleSheet,
Text,
Image,
View,
ListView,
} from 'react-native';
//import {AppRegistry,} from 'react-native';
//import Day0718 from './componets/Home'
export default class Day0718 extends Component {
constructor(props) {
super(props);
let movies = [
{title: '肖申克的救赎'},
{title: '这个杀手不太冷'},
{title: '阿甘正传'},
{title: '霸王别姬'},
{title: '美丽人生'},
];
let dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
movies: dataSource.cloneWithRows(movies)
};
}
render() {
return (
<View style={styles.Container}>
<ListView
dataSource={this.state.movies}
renderRow={
movie => <Text style={styles.itemText}>{movie.title} </Text>
}
/>
</View>
);
}
}
const styles = StyleSheet.create({
overlay: {
backgroundColor: 'rgba(0,0,0,0.3)',
alignItems: 'center'
},
overlayHeader: {
fontSize: 33,
fontFamily: 'Helvetica Neue',
fontWeight: '200',
color: '#eae7ff',
padding: 10
},
overlaySubHeader: {
fontSize: 16,
fontFamily: 'Helvetica Neue',
fontWeight: '200',
color: '#eae7ff',
padding: 10,
paddingTop: 0,
},
backImage: {
// alignItems:'center',
flex: 1,
//justifyContent:'center',
resizeMode: 'cover',
},
image: {
height: 200,
width: 100,
justifyContent: 'center',
},
item: {
backgroundColor: '#fff',
borderWidth: 1,
borderColor: '#6435c9',
margin: 6,
flex: 1,
},
itemOne: {
// alignSelf:'flex-start',
},
itemTwo: {
//alignSelf:'center',
},
itemThree: {
flex: 2,
},
itemText: {
fontSize: 33,
fontFamily: 'Helvetica Neue',
fontWeight: '200',
color: '#6435c9',
padding: 30,
},
Container: {
//alignItems:'flex-start',// flex-start 靠在左边显示 center 居中 flex-end 尾部
//
flexDirection: 'column',//row column 方向
backgroundColor: '#eae7ff',
flex: 1,
//justifyContent:'center',//center ; 居中 flex-end 位于底部 space-between/space-around屏幕平均分配
},
Text: {
color: '#6435c9',
fontSize: 26,
textAlign: 'center',
fontStyle: 'italic',
letterSpacing: 2,
lineHeight: 33,
fontFamily: 'Helvetica Neue',
fontWeight: '300',
textDecorationLine: 'underline',
textDecorationStyle: 'dashed',
},
});
class ComText extends React.Component {
render() {
return (
<Text style={styles.itemText}>
{this.props.children}
</Text>
);
}
}
AppRegistry.registerComponent('Day0718', () => Day0718);
模拟数据 展示ListView
-----------------------------期待大神们的到来
------------------------一---起分享,一起进步!需要你们
React-Native基础_5.列表视图ListView的更多相关文章
- React-Native基础_5.列表视图ListView 网络数据展示
//获取网络数据 并用列表展示 豆瓣Top250 api /** * Sample React Native App * https://github.com/facebook/react-nativ ...
- React Native基础&入门教程:初步使用Flexbox布局
在上篇中,笔者分享了部分安装并调试React Native应用过程里的一点经验,如果还没有看过的同学请点击<React Native基础&入门教程:调试React Native应用的一小 ...
- react native基础与入门
react native基础与入门 一.react native 的优点 1.跨平台(一才两用) 2.低投入高回报 (开发成本低.代码复用率高) 3.性能高:拥有独立的js渲染引擎,比传统的h5+ w ...
- 跨平台框架与React Native基础
跨平台框架 什么是跨平台框架? 这里的多个平台一般是指 iOS 和 Android . 为什么需要跨平台框架? 目前,移动开发技术主要分为原生开发和跨平台开发两种.其中,原生应用是指在某个特定的移动平 ...
- React Native填坑之旅--ListView篇
列表显示数据,基本什么应用都是必须.今天就来从浅到深的看看React Native的ListView怎么使用.笔者写作的时候RN版本是0.34. 最简单的 //@flow import React f ...
- Android 自学之列表视图ListView和ListActivity
ListView是手机系统中使用非常广泛的一种组件,它以垂直列表的形式显示所有列表项. 创建ListView有两种方式: 直接使用ListView创建. 让Activity继承ListActivity ...
- Android——列表视图(ListView)
列表视图是android中最常用的一种视图组件,它以垂直列表的形式列出需要显示的列表项.在android中有两种方法向屏幕中添加列表视图:一种是直接使用ListView组件创建:另外一种是让Activ ...
- 滚动视图、列表视图[ListView、SimpleAdapter类]
滚动视图 <ScrollView android: layout_width="fill_parent" android: layout_height="fill_ ...
- React Native基础&入门教程:调试React Native应用的一小步
React Native(以下简称RN)为传统前端开发者打开了一扇新的大门.其中,使用浏览器的调试工具去Debug移动端的代码,无疑是最吸引开发人员的特性之一. 试想一下,当你在手机屏幕按下一个按钮, ...
随机推荐
- C++实现最基本的LRUCache服务器缓存
目录: 一.介绍: 二.数据结构: 三.主要的两个函数接口Put()和Get(): 四.C++代码实现: 后台开发必备知识,不过我不是搞这个的,只是因为很久以前就想写这些东西,事情多,拖到现在.写的过 ...
- /usr/bin/ld: crti.o: No such file: No such file or directory
Problem : You are running a 64-bit linux system and trying to compile a 32-bit application and you g ...
- [BZOJ2809]dispatching
Description 在一个忍者的帮派里,一些忍者们被选中派遣给顾客,然后依据自己的工作获取报偿.在这个帮派里,有一名忍者被称之为 Master.除了 Master以外,每名忍者都有且仅有一个上级. ...
- class.getResource()和getResourceAsStream的用法
转自:http://blog.csdn.net/lcj8/article/details/3502849 class.getResource()的用法 用JAVA获取文件,听似简单,但对于很多像我这样 ...
- 使用MessageFormat替换字符中的占位符
使用String.format可以实现字符串的格式化功能,即将后面参数中的值替换掉format中的%s,%d这些值.但MessageFormat更为强大,不用管传入值是字符串还是数字,使用占位符即可. ...
- js添加事件 attachEvent 和addEventListener的用法
一般我们在JS中添加事件,是这样子的: obj.onclick = method 这种绑定事件的方式,兼容主流浏览器,但是如果一个元素上添加多次同一个事件呢??? obj.onclick = meth ...
- Java新建线程的3种方法
Java新建线程的3种方法 =================== Java创建线程有3种方法:(1)继承Thread;(2)实现Runnable接口:(3)实现Callable接口; 由于Java只 ...
- yii2打印数据属性(字段名)/数据
yii2打印数据属性(字段名)/数据 单条数据: $model = $this->findModel($id);//打印字段名 $array = $model->attributes(); ...
- Runtime.getRuntime.exec();
杀死Chrome浏览器进程 private static void closeAllChrome() throws IOException{ Runtime.getRuntime().exec(&qu ...
- 委托---.net4.0提供两个比较重要的委托
public delegate void Action<[in T1][,in T2][,in T3]......>([T1 t1][,T2 t2][,T3 t3]...) public ...