创新互联React教程:SwitchAndroid

标准的 Android 双态切换组件

钟楼网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站设计等网站项目制作,到程序开发,运营维护。创新互联从2013年创立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联

属性

disable bool

如果为 true,则该组件不能进行交互。

onValueChange function

当值发生变化时调用新的值。

testID string

用于在端到端测试中查找此视图。

value bool

开关的布尔值。

其他属性:

android:showText:设置on/off的时候是否显示文字,boolean 

android:splitTrack:是否设置一个间隙,让滑块与底部图片分隔,boolean 

android:switchMinWidth:设置开关的最小宽度 

android:switchPadding:设置滑块内文字的间隔 

android:switchTextAppearance:设置开关的文字外观,暂时没发现有什么用… 

android:textOff:按钮没有被选中时显示的文字 

android:textOn:按钮被选中时显示的文字 

android:textStyle:文字风格,粗体,斜体写划线那些 

android:track:底部的图片 

android:thumb:滑块的图片 

例子

    'use strict';

    var React = require('React');

    var SwitchAndroid = require('SwitchAndroid');
    var Text = require('Text');
    var UIExplorerBlock = require('UIExplorerBlock');
    var UIExplorerPage = require('UIExplorerPage');

    var SwitchAndroidExample = React.createClass({
      statics: {
        title: '',
        description: 'Standard Android two-state toggle component'
      },

      getInitialState : function() {        return {
          trueSwitchIsOn: true,
          falseSwitchIsOn: false,
          colorTrueSwitchIsOn: true,
          colorFalseSwitchIsOn: false,
          eventSwitchIsOn: false,
        };
      },

      render: function() {        return (
          ">
            
               this.setState({falseSwitchIsOn: value})}
                style={{marginBottom: 10}}
                value={this.state.falseSwitchIsOn} />
               this.setState({trueSwitchIsOn: value})}
                value={this.state.trueSwitchIsOn} />
            
            
              
              
           
           
              this.setState({eventSwitchIsOn: value})}
               style={{marginBottom: 10}}
               value={this.state.eventSwitchIsOn} />
              this.setState({eventSwitchIsOn: value})}
               style={{marginBottom: 10}}
               value={this.state.eventSwitchIsOn} />
             {this.state.eventSwitchIsOn ? "On" : "Off"}
          
          
            
            
          
        
       );
     }
    });

    module.exports = SwitchAndroidExample;

文章名称:创新互联React教程:SwitchAndroid
本文URL:http://www.shufengxianlan.com/qtweb/news22/150122.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联