<html>

React Native从零開始(十一)Button的使用



React Native在新的版本号中加入了Button的控件,我也忘记是那个版本号了。反正不用像曾经那样我们去自己用TouchableOpacity来写了。怎么说吧我认为有利也有弊。感觉TouchableOpacity更加的灵活吧。


会找时间写一下自己的Button(TouchableOpacity。。。)


一、基本属性

accessibilityLabel string用于给残障人士显示的文本(比方读屏器软件可能会读取这一内容)

color color :文本的颜色(iOS)。或是button的背景色(Android)

disabled bool :设置为true时此button将不可点击

onPress function :用户点击此button时所调用的处理函数


效果图



二、总体的代码

import {
  AppRegistry,
  StyleSheet,
  View,
  Button,
  Alert,
} from 'react-native';
function ClickBtn() {
    alert("aaa");
}
function ChangeDisable() {
    this.setState({
        disabled: this.state.disabled ? false : true
    });
}
export default class ActivityIndicatorDemo extends Component {
  constructor(props){
      super(props);
      /*用来指示是否显示Loading提示符号*/
      this.state = {
          disabled : false,
      }
  }
  render() {
    return (
      <View style={styles.container}>
            <Button
                onPress={ClickBtn}
                title="Learn More"
                color="green"
                disabled={this.state.disabled}
                accessibilityLabel="Learn more about this purple button"
            />
          <Button
              onPress={ChangeDisable.bind(this)}
              title="是否可以点击"
              color="gray"
              accessibilityLabel="Learn more about this purple button"
          />
      </View>
    );
  }
}


版权声明:本文为博主原创文章,未经博主同意不得转载。 举报

相关文章推荐

react native Button 使用具体解释

Button事实上就是 Touchable(TouchableNativeFeedback、TouchableOpacity)和Text封装而来,以下是Button的部分源代码:render() { co...

React Nativebutton具体解释|Touchable系列组件使用具体解释

在做App开发过程中离不了的须要用户交互,说到交互。我们首先会想到的就是button了,在React Native中没有专门的button组件。

为了能让视图可以响应用的的点击事件,我们须要借助Touchablexx...

React Native开发之button的使用

button是移动开发中一个很经常使用的一个控件。在RN中使用button有3种:TouchableHighlight,TouchableOpacity,TouchableWithoutFeedback。 Toucha...

React Native Button实现

使用React Native实现Button的效果: 0. 概述 使用React Native的TouchableHighlight组件包装Text、Image或其它组件。由于To...

React Native 自己定义圆角button的封装

前段时间一直在做react native开发,一直在忙,也没时间写东西,这次就打算认真地写点东西了。 感觉react native开发就是要先写组件(component),然后用组件去组装页面。组...

React-native第一课,Button的加入

react-native第一课之Button的加入

【React Native开发】React Native控件之TextInput组件解说与QQ登录界面实现(11)

(一)前言         今天我们一起来看一下文本输入框TextInput组件的相关使用解说以及模仿实现一下QQ登录界面的效果。详细环境搭建以及相关配置的请查看之前的相关文章。         刚创...

React Native Button使用

属性accessibilityLabel string 用于显示可訪问性功能的文本 color color 文本的颜色(IOS),或button的背景颜色(Android) disabled bool If ...

自用Android资源訪问

Android资源訪问 一、资源訪问:【掌握】 (一)、概念:     Android中的资源是指能够在代码中使用的外部文件,这些文件作为应用程序的一部分。被编译到应用程序中。

在项目中。这些...

Android RecyclerView 具体解释(二) 点击事件绑定、瀑布流和Grid的实现

Android RecyclerView 具体解释(二) 点击事件绑定和瀑布流Grid的实现 一丶点击事件的绑定 我们參考listView的onItemClickListener (1)返回值为v...
  • 微博
    微信
    QQ
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多仅仅同意输入30个字)

posted on 2017-08-17 10:39  ljbguanli  阅读(165)  评论(0编辑  收藏  举报