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的更多相关文章

  1. 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 ...

  2. UIImageWriteToSavedPhotosAlbum

    UIImageWriteToSavedPhotosAlbum: Next UIKit Function Reference Overview The UIKit framework defines a ...

  3. 【IOS笔记】About Events in iOS

    About Events in iOS Users manipulate their iOS devices in a number of ways, such as touching the scr ...

  4. iOS苹果官方Demo合集

    Mirror of Apple’s iOS samples This repository mirrors Apple’s iOS samples. Name Topic Framework Desc ...

  5. 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 ...

  6. Event Handling Guide for iOS--(二)---Gesture Recognizers

    Gesture Recognizers 手势识别器 Gesture recognizers convert low-level event handling code into higher-leve ...

  7. 移动端事件对象touches的误区

    不想长篇大论,也是自己遗留下的一个错误的理解 在移动端触屏事件有四个 // 手势事件 touchstart //当手指接触屏幕时触发 touchmove //当已经接触屏幕的手指开始移动后触发 tou ...

  8. touch事件中的touches、targetTouches和changedTouches详解

    touches: 当前屏幕上所有触摸点的列表; targetTouches: 当前对象上所有触摸点的列表; changedTouches: 涉及当前(引发)事件的触摸点的列表 通过一个例子来区分一下触 ...

  9. touches 事件捕获不到

    在UIView上加载了一个UIScrollView(全屏),touches 事件捕获不到了 原因:UIView的touch事件被UIScrollView捕获了,无法传递下去 解决方法:写一个UIScr ...

随机推荐

  1. js如何在浏览器添加cookie(添加、获取、删除)

    首先,简单用js将cookie保存到浏览器中,具体可按F12在这里查看(火狐浏览器) 1.js脚本方法 1)添加cookie方法 //添加cookie var addCookie = function ...

  2. 移动web技能总结

    对于作为一名前端开发人员,除了能够编写出满足需求的PC端页面之外,同时也是需要懂得怎么去制作移动web页面,毕竟使用移动设备来操作任何处理称为新时代的趋势,所以学好制作一个移动web时必须滴.于是通过 ...

  3. C# 远程传输File文件

    /// <summary> /// 向论坛传图片文件 /// </summary> /// <param name="filePath">< ...

  4. n阶楼梯,一次走1,2,3步,求多少种不同走法

    ##已知n阶楼梯,一次可以迈1,2,3步.求所有走法## 如果要列出走法,时间复杂度太高,O(n)=2**n,前两个函数遍历走法.## 如果只是单纯列出走法数量,就简单多了,也但是很容易内存爆表. # ...

  5. linux基本网络配置

    -- linux基本网络配置管理 rhel6开始有一个networkmanger的网络配置服务(可以图形配置网络,拔号,无线连接,vpn等)但此服务开启会造成你的ip不固定(会dhcp获取),而且后期 ...

  6. UVALive - 4223,hdu2962(简单dijkstra)

    Trucking Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. HTML5:定位

    定位 一.介绍: position设置块级元素相对于其父块的位置和相对于它自身应该在的位置,任何使用定位的元素都会成为块级元素. 1.属性值 属性值 描述 absolute 生成绝对定位的元素,相对于 ...

  8. MFC VC++获取当前程序的运行路径

    ]; GetModuleFileName(, szDir, ); int i; i = lstrlen(szDir) - ; ) { if(szDir[i] == _T('\\')) { szDir[ ...

  9. 剑指Offer 25. 复杂链表的复制 (链表)

    题目描述 输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点),返回结果为复制后复杂链表的head.(注意,输出结果中请不要返回参数中的节点引用,否 ...

  10. 莫烦tensorflow(8)-CNN

    import tensorflow as tffrom tensorflow.examples.tutorials.mnist import input_data#number 1 to 10 dat ...