ListView-电影列表
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-电影列表的更多相关文章
- [Python] 抓取时光网的电影列表并生成网页
抓取时光网的电影列表并生成网页 源码 https://github.com/YouXianMing/BeautifulSoup4-WebCralwer 分析 利用BeautifulSoup进行分析网页 ...
- 【VIP视频网站项目一】搭建视频网站的前台页面(导航栏+轮播图+电影列表+底部友情链接)
首先来直接看一下最终的效果吧: 项目地址:https://github.com/xiugangzhang/vip.github.io 在线预览地址:https://xiugangzhang.githu ...
- 图解微信小程序---获取电影列表
图解微信小程序---获取电影列表 代码笔记 list跳转 第一步:编写前端页面获取相关的电影列表参数(对于显示参数不熟悉,可以先写js,通过console Log的方式获取我们电影的相关数据字段,后 ...
- react-native构建基本页面4---渲染电影列表
电影列表 import React, { Component } from 'react' import { View, Image, Text, ActivityIndicator, FlatLis ...
- ListView 基础列表组件、水平 列表组件、图标组件
一.Flutter 列表组件概述 列表布局是我们项目开发中最常用的一种布局方式.Flutter 中我们可以通过 ListView 来定义 列表项,支持垂直和水平方向展示.通过一个属性就可以控制列表的显 ...
- Android通过LIstView显示文件列表
[绥江一百]http://www.sj100.net 欢迎,进入绥江一百感谢点击[我的小网站,请大家多 ...
- Android(java)学习笔记186:对ListView等列表组件中数据进行增、删、改操作
1.ListView介绍 解决大量的相似的数据显示问题 采用了MVC模式: M: model (数据模型) V: view (显示的视图) C: controller 控制器 入门案例: acit ...
- 第二章实例:SimpleAdapter结合listview实现列表视图
package test.simpleAdapter; import java.util.ArrayList; import java.util.HashMap; import java.util.L ...
- react-native实现电影列表
页面运行效果 代码: import React, { Component } from "react"; import { Image, FlatList, StyleSheet, ...
- 安卓开发——ListView控件(初始化ListView、列表刷新、长按添加menu)
前言: ListView——列表,它作为一个非常重要的显示方式,不管是在Web中还是移动平台中,都是一个非常好的.不开或缺的展示信息的工具.在Android中,ListView控件接管了这一重担,在大 ...
随机推荐
- list<?>转换成 对应的 class
项目中用到的,list转换成bean.因为查询出来的数据用list 泛型接收,要返回 实体对象.所以需要对应转换. 主要用到的技术:反射. 上代码: public static <T> L ...
- jenkins持续集成之Global Tool Configuration的配置
Global Tool Configuration的配置过程: 1.点击系统管理2.点击 Global Tool Configuration3.必须配置: jdk git ant maven 1.点击 ...
- javascript总结21:javascript-JSON与遍历
1 什么是JSON JavaScript Object Notation(JavaScript对象表示形式) JavaScript的子集 JSON和对象字面量的区别 JSON的属性必须用双引号引号引起 ...
- HDU 5792 World is Exploding (离散化+树状数组)
题意:给定 n 个数,让你数出 a < b && c < d && a != b != c != d && Aa < Ab & ...
- 七)oracle 2 mysql
/* Navicat MySQL Data Transfer Source Server : localhost Source Server Version : 50527 Source Host : ...
- org.eclipse.wst.common.project.facet.core.xml
Ctrl+Shift+R *core.xml 修改Dynamic Web module 由3.1 切至2.几
- Currying and Uncurrying Js
//反科里化Function.prototype.uncurrying = function() { var _this = this; return function() { return Func ...
- 编写高质量代码改善C#程序的157个建议——建议123:程序集不必与命名空间同名
建议123:程序集不必与命名空间同名 程序集一般会和命名空间同名,但这并不是必须的.事实上,不同名的命名空间和程序集是很常见的. 程序集表示的是一种物理上的分组,而命名空间是逻辑上的分组,两者没有必然 ...
- 编写高质量代码改善C#程序的157个建议——建议84:使用PLINQ
建议84:使用PLINQ LINQ最基本的功能就是对集合进行遍历查询,并在此基础上对元素进行操作.仔细推敲会发现,并行编程简直就是专门为这一类应用准备的.因此,微软专门为LINQ拓展了一个类Paral ...
- 盒子模型 以及CSS的box-sizing属性。
盒子模型有两种 一种是 内容盒子模型 一种是边框盒子模型. 内容盒子模型(标准盒子模型)由width和height中指定的元素的尺寸不包括内边距和边框 仅是指的内容的实际尺寸: 网上搜索了两张配图不错 ...