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. 19-字符切割函数c++模板

    https://www.cnblogs.com/stonebloom-yu/p/6542756.html #include <cstring> #include <cstdio> ...

  2. [C++] 2D Array's memory allocation

    2D Array's memory allocation

  3. Linux 添加新硬盘

    1.识别分区和硬盘 在 /dev/ 目录下找到新的硬盘,sda 为本地硬盘,sda1.sda2.. 为分区,sdb 就是新添加的硬盘,如: [root@wusuyuan ~]# ls -ltr /de ...

  4. idea hibernate jpa 生成实体类

    0,添加mysql数据库连接 1,生成个hibernate.cfg.xml 2,打开Persisitence 3,Import Databases Schema 4,选择表生成实体类

  5. vue相关操作

    一: vue的安装 -安装node.js -vue脚手架 -vue create 项目名字 二:vue create 项目名字 用pycharm打开vue项目 -需要安装vue.js插件-settin ...

  6. mysql 存储过程学习(总)

    #一.存储过程和存储函数的创建案例 CREATE PROCEDURE myprocedure(in a int,in b int ,OUT c INT) BEGIN set c=a+b; end; c ...

  7. [GO]非结构体匿名字段

    package main import ( "fmt" ) type mystr string //给一个类型重命名 type Person struct { name strin ...

  8. Ubuntu 将应用程序 固定到快快速启动栏(以Sublime为例)

    因为Sublime Text并不是需要安装,所以缺少Ubuntu桌面运行的一些基本配置,比如不能将它加入桌面侧边的启动器. 而Ubuntu上也没有快捷方式的说法,而通过软件中心安装的软件就有图标,并能 ...

  9. T4模板调用反射

    <#@ template debug="false" hostspecific="true" language="C#" #> ...

  10. java 调用javascript

    首先我们在D盘的根目录下有一个js文件 名叫 common.js 假设里面有一个这样的方法 /** * @param int *            _number 你想要的最大值 * @param ...