Handling Touches - RN3
1. basic button
format:
<tag event caption />
<Button
onPress={{}}
title="I am button"
/>
<Button
onPress={() => {
Alert.alert("You are Right!");
}}
title="Push me"
/>
Usage:
(1) import
import {Button, Alert} from "react-native";
(2) src
import React from 'react';
import { StyleSheet, Text, View, Button, Alert } from 'react-native'; export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<Button
onPress={() => {
Alert.alert("You are Right!");
}}
title="Push me"
/>
</View>
);
}
} const styles = StyleSheet.create({
container: {
flex: ,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
2. Actual button
format:
<tag event caption />
<TouchableHighlight event>
<View>
<Text>caption</Text>
</View>
</TouchableHighlight>
for example:
<TouchableHighlight onPress={this._onPressButton} underlayColor="white">
<View style={styles.button}>
<Text style={styles.buttonText}>I am a rounded button</Text>
</View>
</TouchableHighlight>
Usage:
(1) import
import {Platform, TouchableHightlight} from "react-native"
(2) src
import React from 'react';
import { StyleSheet, Text, View, Platform, TouchableHighlight, Alert } from 'react-native'; export default class App extends React.Component {
_onPressButton() {
Alert.alert('You tapped the button!')
} render() {
return (
<View style={styles.container}>
<TouchableHighlight onPress={this._onPressButton} underlayColor="white">
<View style={styles.button}>
<Text style={styles.buttonText}>I am a rounded button</Text>
</View>
</TouchableHighlight>
</View>
);
}
} const styles = StyleSheet.create({
container: {
paddingTop: ,
alignItems: 'center'
},
button: {
marginBottom: ,
width: ,
alignItems: 'center',
backgroundColor: '#2196F3',
borderRadius:
},
buttonText: {
padding: ,
color: 'white'
}
});
Reference:
1. Handling Touches - Displaying a basic button
2. Handling Touches - Touchables
Handling Touches - RN3的更多相关文章
- Event Handling Guide for iOS--(一)--About Events in iOS
About Events in iOS Users manipulate their iOS devices in a number of ways, such as touching the scr ...
- UIImageWriteToSavedPhotosAlbum
UIImageWriteToSavedPhotosAlbum: Next UIKit Function Reference Overview The UIKit framework defines a ...
- 【IOS笔记】About Events in iOS
About Events in iOS Users manipulate their iOS devices in a number of ways, such as touching the scr ...
- iOS苹果官方Demo合集
Mirror of Apple’s iOS samples This repository mirrors Apple’s iOS samples. Name Topic Framework Desc ...
- Event Handling Guide for iOS--(三)---Event Delivery: The Responder Chain
Event Delivery: The Responder Chain 事件传递:响应链 When you design your app, it’s likely that you want to ...
- Event Handling Guide for iOS--(二)---Gesture Recognizers
Gesture Recognizers 手势识别器 Gesture recognizers convert low-level event handling code into higher-leve ...
- 移动端事件对象touches的误区
不想长篇大论,也是自己遗留下的一个错误的理解 在移动端触屏事件有四个 // 手势事件 touchstart //当手指接触屏幕时触发 touchmove //当已经接触屏幕的手指开始移动后触发 tou ...
- touch事件中的touches、targetTouches和changedTouches详解
touches: 当前屏幕上所有触摸点的列表; targetTouches: 当前对象上所有触摸点的列表; changedTouches: 涉及当前(引发)事件的触摸点的列表 通过一个例子来区分一下触 ...
- touches 事件捕获不到
在UIView上加载了一个UIScrollView(全屏),touches 事件捕获不到了 原因:UIView的touch事件被UIScrollView捕获了,无法传递下去 解决方法:写一个UIScr ...
随机推荐
- windows server下设置远程会话自动注销
通过远程桌面连接windows server服务器时,经常是直接关闭远程桌面程序,而没有注销远程登录的用户,这样导致有很多远程桌面启动的进程依然运行在服务器上,对服务器产生了不必要的开销,其实作为se ...
- php7安装 event扩展
1 下载地址:http://pecl.php.net/package/event 2 安装支持库libevent,需要编译高版本(这里以最新版本release-2.1.8-stable为例) http ...
- Quartz定时器+Spring + @Autowired注入 空指针异常
在Quartz的定时方法里引用@Autowired注入Bean,会报空指针错误 解决办法: 第一种方法:(推荐,简单,亲测可行) 使用@Resource(name="指定要注入的Bean&q ...
- Mad Libs游戏 & 华氏温度与摄氏温度转换
Mad Libs游戏 animal1 = input("请输入一种动物") animal2 = input("请输入一种动物") movement1 = inp ...
- java中求余%与取模floorMod的区别
初学java的时候接触的%这个符号 百分号? 求余? 取模? 我只知道不是百分号,好像是求余,听别人那叫求模运算符,跟求余一样,于是我便信了. 思考之后开始迷糊,然后经过多次考证得到以下结论. 首先, ...
- VC++、MFC Sqlite3数据库的使用
SQLite数据库是一种本地的轻型数据库,在存储一些本地的数据的时候,或者不需要用到Oracle,SQL2008之类的大型数据库的时候,Sqlite的优势就能够得到发挥.程序需要采集数据存储起来,可以 ...
- 使用CSMA/CD协议一个计算题
题干: 首先计算一下A这个以太网所容许的最短的帧它的发送帧的长度时间为: (8(前同步码为8)+64(最短帧长))*8(单位转换b到B)=576比特 有关于单位转换: B是Byte的缩写,B就是Byt ...
- 直接借鉴的 ids拼接
function _getIds(selectedIds, targetType){ var ids = ""; var $box = targetType == "di ...
- PHP 打开已有图片进行编辑
<?php header("content-type:image/jpeg");//表明请求页面的内容是jpeg格式的图像 即当前页面会以图片的新式展示 去掉这行就可以显示正 ...
- ubuntu 菜单栏和终端都消失了,鼠标也成了一个× 解决办法!!!
办法1: ctrl+alt+f1 进入命令模式 依次下载 sudo apt-get update sudo apt-get install --reinstall ubuntu-desktop su ...