zoukankan      html  css  js  c++  java
  • RN TextInput用法

    效果图:

    代码:

    import React, {Component} from 'react'
    import {StyleSheet, View, Text, TouchableOpacity, TextInput} from 'react-native'
    
    class TextInputView extends Component {
    
        constructor(popps) {
            super(popps);
            this.state = {
                text: ''
            }
    
        }
    
        hide(val) {
            this.setState({
                show: false, value: val
            })
        }
    
        getValue(text) {
            var value = text;
            this.setState({
                show: true, value: value
            })
        }
    
    
        render() {
    
            return (
                <View style={styles.container} accessible={true}>
                    <TextInput style={styles.styleInput}
                               returnKeyLabel={"search"}
                               placeholder={"请输入搜索的关键字"}
                               onEndEditing={this.hide.bind(this, this.state.value)}
                               onChangeText={this.getValue.bind(this)}
                    />
    
                    <Text style={styles.styleText}>搜索结果</Text>
                    {this.state.show ?
                        <View style={[styles.styleResult]}>
                            <Text onPress={this.hide.bind(this, this.state.value + "街")} style={styles.item}
                                  numberOfLines={1}>
                                {this.state.value}街
                            </Text>
                            <Text onPress={this.hide.bind(this,this.state.value+"车站")} style={styles.item}
                            numberOfLines={1}>
                                {this.state.value}车站
                            </Text>
                        </View> : null
                    }
    
                </View>
            );
        }
    
    
    }
    
    const styles = StyleSheet.create({
        container: {
            flex: 1,backgroundColor: '#ffffff',marginTop: 20
        },
        styleInput: {
            height:40,borderWidth: 1,marginLeft: 10,marginRight: 10,paddingLeft: 5,borderColor:'#cccccc',borderRadius:4
        },
        styleResult:{
            marginLeft:15,marginTop:10
        },
        styleText: {
            fontSize: 16,marginTop: 10,marginLeft:15
        },
        styleItem: {
            fontSize:18,padding: 5,paddingTop: 10,paddingBottom: 10,marginLeft: 15,borderColor: '#dddddd',borderTopWidth: 0
        }
    
    });
    
  • 相关阅读:
    004-DQN
    003-sarsa
    002-Q Leaning
    001-强化学习简介
    阿里云GPU服务器配置深度学习环境-远程访问-centos,cuda,cudnn,tensorflow,keras,jupyter notebook
    003-keras模型的保存于加载
    004-linux常用命令-网络命令
    004-linux常用命令-压缩解压命令
    004-linux常用命令-添加管理员用户
    004-linux常用命令-用户管理命令
  • 原文地址:https://www.cnblogs.com/hualuoshuijia/p/10132400.html
Copyright © 2011-2022 走看看