react native RefreshControl 使用详解
来源:互联网 发布:cnzz数据统计 编辑:程序博客网 时间:2024/06/05 12:06
RefreshControl 可以用在ScrollView或ListView 的refreshControl属性上,用于下拉刷新。
onRefresh:开始刷新时调用
refreshing:设置为true显示指示器,false:隐藏。
colors(android):指示器颜色,可以多个,循环显示。
progressBackgroundColor(android):指示器背景颜色
size(android):值:[0,1]。指示器大小,默认1,0:large
progressViewOffset(android):指示器距离顶部的位置,默认0.
tintColor(ios):指示器颜色
title(ios):指示器下显示的文字
titleColor(ios):指示器下显示的文字的颜色
/** * Created by on 2017/5/17. */import React, {Component} from 'react';import { StyleSheet, View, Text, ScrollView, RefreshControl,} from 'react-native';export default class RefreshControlDemo extends Component { static navigationOptions = { title: 'RefreshControl', }; state = { loaded:0, isRefreshing: false, data: Array.from(new Array(20)).map((val, i) => ({text: '初始化: ' + i, clicks: 0})), } _onRefresh = () => { this.setState({isRefreshing: true}); setTimeout(() => { // prepend 10 items const rowData = Array.from(new Array(10)) .map((val, i) => ({ text: '第几次加载: ' + (+this.state.loaded + i), clicks: 0, })) .concat(this.state.data); this.setState({ loaded: this.state.loaded + 10, isRefreshing: false, data: rowData, }); }, 3000); } render() { return ( <ScrollView style={{flex:1}} refreshControl={ <RefreshControl refreshing={this.state.isRefreshing} onRefresh={this._onRefresh} tintColor="#ff0000" title="Loading..." titleColor="#00ff00" size={0} progressViewOffset={30} colors={['#0000ff','#ff0000', '#00ff00', ]} progressBackgroundColor="#ffff00" /> }> <View> { this.state.data.map((row, ii) => { return (<Text>{row.text}</Text>); }) } </View> </ScrollView> ); }}
github下载地址
阅读全文
0 0
- react native RefreshControl 使用详解
- React-Native- RefreshControl && Navigator 使用案例
- 【React Native开发】React Native控件之RefreshControl组件详解(21)
- react native RefreshControl下拉控件 右上角默认出现小菊花
- react native listview 实现下拉刷新(RefreshControl)
- react native学习笔记12——RefreshControl下拉刷新
- react native ActivityIndicator使用详解
- react native Button 使用详解
- react native Text 使用详解
- react native Switch使用详解
- react native ScrollView 使用详解
- react native FlatList 使用详解
- react native SectionList 使用详解
- react native TextInput 使用详解
- react native Slider 使用详解
- react native StatusBar 使用详解
- react native DatePickerIOS 使用详解
- react native DrawerLayoutAndroid 使用详解
- qt串口通信学习笔记
- 【错误】java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
- ASP.NET WebAPI 实战问题总结(一)
- 网络编程中Nagle算法和Delayed ACK的测试
- 解决:Gradle project refresh failed Failed to open zip file 方法
- react native RefreshControl 使用详解
- php 下线预览pdf
- 大端与小端存储模式详解
- 【云栖风向标】VOL.1:勒索病毒频发!445端口守护指南
- 关于Android手机设置好Vpn之后无法连接到服务器
- JVM 内存模型和垃圾回收(四): 并发回收(Concurrent Mark-Sweep Collector)
- spring boot
- NGN-android开发中的知识点(二)
- Linux常用命令