import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View,
ListView } from 'react-native'; //从文件中读取数据(ES5)
var movieData = require("./data.json");
//获取所有movies数据,属性movies是一个数组
var movies = movieData.movies; //ES6 读取本地 json
import moviesData from "./movie.json";
var movies = moviesData.links;
var MovieList = React.createClass({

    getInitialState:function () {
//创建dataSource对象
var ds = new ListView.DataSource({
rowHasChanged:(oleRow,newRow) => oleRow!==newRow
});
return{
dataSource : ds.cloneWithRows(movies)
}
},
//渲染行组件
_renderRow:function (movie) {
return(
<View style={styles.row}>
<Image
style={styles.thumbnail}
source={{uri:movie.posters.thumbnail}}//图像的链接
/>
<View style={styles.rightContainer}>
<Text style={styles.title}>{movie.title}</Text>
<Text style={styles.year}>{movie.year}</Text>
</View>
</View>
)
},
//渲染头部
_renderHeader:function () {
return(
<View style={styles.header}>
<Text style={styles.headerText}>Movies List</Text>
<View style={styles.separator}></View>
</View>
) },
//渲染分割线
_renderSepatator:function (sectionID:number,rowID:number) {
return(
//view作为分割线
<View style={styles.separator} key={sectionID+rowID}></View>
)
}, render:function () {
return(
<ListView
style={styles.listView}
dataSource={this.state.dataSource}
renderRow={this._renderRow}
renderHeader={this._renderHeader}
renderSeparator={this._renderSepatator}
initialListSize={10} //开始时 渲染多少行
/> )
}
}); var styles = StyleSheet.create({ listView:{
marginTop:25,
flex:1,
backgroundColor:"#F5FCFF"
},
//行组件样式
row:{
flexDirection:"row",
padding:5,
alignItems:"center",
backgroundColor:"#F5FCFF"
},
thumbnail:{
width:53,
height:81,
backgrounColor:"gray"
},
rightContainer:{
marginLeft:10,
flex:1,
},
title:{
fontSize:18,
marginTop:3,
marginBottom:3,
textAlign:"center",
},
year:{
marginBottom:3,
textAlign:"center",
},
//header组件样式
header:{
height:50,
backgroundColor:"#F5FCFF"
},
headerText:{
flex:1,
fontSize:20,
fontWidth:"bold",
textAlign:"center",
lineHeight:44
},
//分割线组件样式
separator:{
height:1,
backgrounColor:"CCCCCC" } });

ListView-电影列表的更多相关文章

  1. [Python] 抓取时光网的电影列表并生成网页

    抓取时光网的电影列表并生成网页 源码 https://github.com/YouXianMing/BeautifulSoup4-WebCralwer 分析 利用BeautifulSoup进行分析网页 ...

  2. 【VIP视频网站项目一】搭建视频网站的前台页面(导航栏+轮播图+电影列表+底部友情链接)

    首先来直接看一下最终的效果吧: 项目地址:https://github.com/xiugangzhang/vip.github.io 在线预览地址:https://xiugangzhang.githu ...

  3. 图解微信小程序---获取电影列表

    图解微信小程序---获取电影列表 代码笔记 list跳转 第一步:编写前端页面获取相关的电影列表参数(对于显示参数不熟悉,可以先写js,通过console  Log的方式获取我们电影的相关数据字段,后 ...

  4. react-native构建基本页面4---渲染电影列表

    电影列表 import React, { Component } from 'react' import { View, Image, Text, ActivityIndicator, FlatLis ...

  5. ListView 基础列表组件、水平 列表组件、图标组件

    一.Flutter 列表组件概述 列表布局是我们项目开发中最常用的一种布局方式.Flutter 中我们可以通过 ListView 来定义 列表项,支持垂直和水平方向展示.通过一个属性就可以控制列表的显 ...

  6. Android通过LIstView显示文件列表

    [绥江一百]http://www.sj100.net                                                  欢迎,进入绥江一百感谢点击[我的小网站,请大家多 ...

  7. Android(java)学习笔记186:对ListView等列表组件中数据进行增、删、改操作

    1.ListView介绍 解决大量的相似的数据显示问题 采用了MVC模式: M: model (数据模型) V:  view  (显示的视图) C: controller 控制器 入门案例: acit ...

  8. 第二章实例:SimpleAdapter结合listview实现列表视图

    package test.simpleAdapter; import java.util.ArrayList; import java.util.HashMap; import java.util.L ...

  9. react-native实现电影列表

    页面运行效果 代码: import React, { Component } from "react"; import { Image, FlatList, StyleSheet, ...

  10. 安卓开发——ListView控件(初始化ListView、列表刷新、长按添加menu)

    前言: ListView——列表,它作为一个非常重要的显示方式,不管是在Web中还是移动平台中,都是一个非常好的.不开或缺的展示信息的工具.在Android中,ListView控件接管了这一重担,在大 ...

随机推荐

  1. C++ std::unordered_multimap

    std::unordered_multimap template < class Key, // unordered_multimap::key_type class T, // unorder ...

  2. RedisHelper in C#

    自己写了一个RedisHelper,现贴出来,希望各位大神能够指正和优化. using System; using StackExchange.Redis; using System.Configur ...

  3. [C#] readonly vs const

    C#中的readonly和const两个关键字都可以用来定义系统变量,那两者之间有什么区别呢? 1. const变量赋值后,就不可以对其进行修改.且在定义时就需要给它赋值,使用const修饰的变量是s ...

  4. Yii项目开发总结

    学习Yii很久了,一直做的是小案例,自以为学的还不错.直到最近用Yii开发了一个非常简单的CMS,一路下来,磕磕绊绊,才知自己不足.加上最近正学习着偏架构方面的知识.特此总结一下.小白经验,大神轻拍, ...

  5. java之常用的依赖文件pom.xml

    <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://mave ...

  6. Java Decompiler(Java反编译工具)

    参考:http://blog.csdn.net/yulei_qq/article/details/24175547 Java Decompiler可以对整个jar包进行反编译,也可以将其集成到ecli ...

  7. 高并发Redis(Mac)环境配置(一)

    一.产生原因: SNS交互型网站的兴起,对于高并发,大负载数据的操作,海量数据的存储和访问 NoSql四种类型: 键值存储(Redis优点可以快速查询,缺点缺少存储的结构化)              ...

  8. WordPaster-Joomla_3.4.7-tinymce 4.1.7示例发布

    资源下载:Joomla 3x,   1.1.1. 1.添加wordpaster文件夹 /media/   1.1.2. 2.添加插件文件夹 路径:media/editors/tinymce/plugi ...

  9. “hdfs dfs -ls”命令的使用

    "hdfs dfs -ls"带一个参数,如果参数以"hdfs://URI"打头表示访问HDFS,否则相当于ls. 其中URI为NameNode的IP或主机名,可 ...

  10. Local Notification

    大家都知道Push Notification,这个东西需要联网才可以用.iOS4起,苹果引入了一种可以在设备内部引发的notification.不需要复杂的服务器编程,或其他复杂的配置.这个技术就是L ...