效果图:

代码:

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
} });

RN TextInput用法的更多相关文章

  1. row_number() over(partition by a order by b desc) rn 用法

    转载于:http://www.blogjava.net/kxbin/articles/360195.html 可以看看http://jingyan.baidu.com/article/9989c746 ...

  2. RN控件之TextInput

    /** * Sample React Native App * https://github.com/facebook/react-native */ 'use strict'; import Rea ...

  3. 【RN - 基础】之TextInput使用简介

    TextInput组件允许用户在应用中通过键盘输入文本信息,其使用方法和Text.Image一样简单,实例代码如下: <TextInput placeholder={'请输入用户名'} styl ...

  4. [RN] React Native 键盘管理 在Android TextInput遮盖,上移等问题解决办法

    React Native 键盘管理 在Android TextInput遮盖,上移等问题解决办法 解决办法: 打开android工程,在AndroidManifest.xml中配置如下: <ac ...

  5. RN import ** from ** 用法

    1.import React, { Component } from 'react': 导入‘react’文件里export的一个默认的组件,将其命名为React以及Component这个非默认组件 ...

  6. React Native随笔——组件TextInput

    一.实例 先看一下我要做的搜索框的样子 需要一个Image,和一个TextInput 去掉默认下划线 underlineColorAndroid='transparent' 设置光标颜色 select ...

  7. 【Win 10 应用开发】Sqlite 数据库的简单用法

    如果老周没记错的话,园子里曾经有朋友写过如何在 UWP 项目中使用 Sqlite数据库的文章.目前我们都是使用第三方封装的库,将来,SDK会加入对 Sqlite 的支持. 尽管目前 UWP-RT 库中 ...

  8. React Native 之 TextInput使用

    前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...

  9. Oracle用法、函数备忘记录

    Listagg select * from emp select LISTAGG(ename,'-') within group (order by deptno desc) from emp; 可以 ...

随机推荐

  1. 基于Jersey使用Session

    原文:https://stackoverflow.com/questions/909185/jersey-security-and-session-management 方法一.注入HttpServl ...

  2. 使用UWA GOT优化Unity性能和内存

    优化百科: https://blog.uwa4d.com/archives/Index.html https://blog.uwa4d.com/archives/Introduction_UWAGOT ...

  3. 仿迅雷播放器教程 -- 基于VLC的C++播放器 (4)

    经过前面的介绍,想必大家对VLC和ffmpeg都有一定印象了,还记得学习ffmpeg多么蛋疼吗?那么VLC会不会也这么蛋疼呢?     那么我们来看一段官方的Demo,Alberl精简了Demo,只留 ...

  4. go语言内置基础类型

    1.数值型(Number) 三种:整数型.浮点型和虚数型(有符号整数表示整数范围 -2n-1~2n-1-1:无符号整数表示整数范围 0~2n-1) go内置整型有:uint8, uint16, uin ...

  5. UML中类结构图示例

  6. solus 系统 - 怎么使用中文输入法?

    系统默认使用 ibus 输入法框架. 可以安装 ibus-libpinyin $ sudo eopkg install ibus-libpinyin 安装好之后需要初始化 ibus-setup $ i ...

  7. JQ-总结

    -----------------------------------------------------------------------------jQuery----------------- ...

  8. $(").each 和$.each

    $(").each 这个是遍历dom树的,遍历数组的会报not afunction

  9. Inotify+rsync实现实时数据同步

    使用rsync可以实现数据同步,但是即使使用crontab定时任务最小执行间隔为1分钟,在数据实时性要求比较高场合需使用inotify+rsync实现实时同步 下载inotify wget https ...

  10. CentOS7 vsftpd 安装及配置

    0x:卸载vsftpd [root@localhost ~]# yum remove vsftpd [root@localhost ~]# find / -name "vsftpd*&quo ...