React-native iOS简单ListView范例-如何输出不同的cell

'use strict'

var React = require('react-native');
var{
    ListView,
    View,
    Text,
    StyleSheet,
    View,
    Switch,
    number,
    string
} = React;

var styles = StyleSheet.create({
                               rowContainer:{
                               flexDirection:'row',
                               height:68,
                               alignItems:'center',
                               borderBottomColor: '#E0E0E0',
                               borderBottomWidth: 1
                               },
                               
                               cellTextAttributes:{
                               fontSize:19,
                               color:'#333333',
                               left:30,
                               alignItems:'center',
                               justifyContent:'center',
                               flex:1
                               },
                               
                               separator: {
                               height: 3,
                               backgroundColor: '#000',
                               marginLeft:16
                               },
                               
                               switchStyle:{
                               marginRight:30,
                               alignItems:'flex-end'
                               }
});

class WebViewExample extends React.Component{
    
    constructor(props) {
        super(props);
        var dataSource = new ListView.DataSource(
            {rowHasChanged: (r1, r2) => r1 !== r2});
        this.state = {
            dataSource: dataSource.cloneWithRows(['推送', '清除缓存','关于我们','我要反馈']),
        };
     }
    
 
    
    renderRow(rowData,sectionID,rowID){
        
        if(rowID === '0'){
            return (
                    <View  style={ styles.rowContainer}>
                    <Text style = {styles.cellTextAttributes}>{rowData}</Text>
                    <Switch style = {styles.switchStyle} disabled = {false} value = {true}/>
                    </View>
            );
        }
        
        return (
                <View  style={ styles.rowContainer}>
                <Text style = {styles.cellTextAttributes}>{rowData}</Text>
                </View>
        );
    }

    render() {
        return (
            <ListView
            dataSource={this.state.dataSource}
            renderRow={this.renderRow.bind(this)}
            />
        );
    }
}

React.AppRegistry.registerComponent('WebViewExample', function() { return WebViewExample});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值