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
}
});
RN TextInput用法的更多相关文章
- 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 ...
- RN控件之TextInput
/** * Sample React Native App * https://github.com/facebook/react-native */ 'use strict'; import Rea ...
- 【RN - 基础】之TextInput使用简介
TextInput组件允许用户在应用中通过键盘输入文本信息,其使用方法和Text.Image一样简单,实例代码如下: <TextInput placeholder={'请输入用户名'} styl ...
- [RN] React Native 键盘管理 在Android TextInput遮盖,上移等问题解决办法
React Native 键盘管理 在Android TextInput遮盖,上移等问题解决办法 解决办法: 打开android工程,在AndroidManifest.xml中配置如下: <ac ...
- RN import ** from ** 用法
1.import React, { Component } from 'react': 导入‘react’文件里export的一个默认的组件,将其命名为React以及Component这个非默认组件 ...
- React Native随笔——组件TextInput
一.实例 先看一下我要做的搜索框的样子 需要一个Image,和一个TextInput 去掉默认下划线 underlineColorAndroid='transparent' 设置光标颜色 select ...
- 【Win 10 应用开发】Sqlite 数据库的简单用法
如果老周没记错的话,园子里曾经有朋友写过如何在 UWP 项目中使用 Sqlite数据库的文章.目前我们都是使用第三方封装的库,将来,SDK会加入对 Sqlite 的支持. 尽管目前 UWP-RT 库中 ...
- React Native 之 TextInput使用
前言 学习本系列内容需要具备一定 HTML 开发基础,没有基础的朋友可以先转至 HTML快速入门(一) 学习 本人接触 React Native 时间并不是特别长,所以对其中的内容和性质了解可能会有所 ...
- Oracle用法、函数备忘记录
Listagg select * from emp select LISTAGG(ename,'-') within group (order by deptno desc) from emp; 可以 ...
随机推荐
- 如何查看tomcat启动异常日志详情
我的电脑同时使用两个jdk版本,默认1.7,eclipse使用的是1.8,,由于项目启动时有加载类需要jdk1.8的包,1.7不支持.所以导致项目在eclipse直接能够跑,而在外面的tomcat跑是 ...
- Android UI布局之RelativeLayout
RelativeLayout是一个相对布局类. 首先RelativeLayout是一个容器,它里边的元素,如Buttonbutton等的位置是依照相对位置来计算的,比如,有两个Buttonbutton ...
- 【代码审计】XYHCMS V3.5任意文件下载漏洞分析
0x00 环境准备 XYHCMS官网:http://www.xyhcms.com/ 网站源码版本:XYHCMS V3.5(2017-12-04 更新) 程序源码下载:http://www.xyhc ...
- 【转载】eclipse常用插件在线安装地址或下载地址
一,反编译插件: A.Jadclipse 1.打开eclipse增加站点:http://jadclipse.sf.net/update,在线安装好JDT Decompiler 3.4.0 2.http ...
- docker 怎么下载指定版本的镜像文件
在使用Docker时我想pull远端仓库的CentOS 6的镜像,但是我直接搜索下载下来的是最新的版本.那我有没有什么办法直接下载Centos6呢? 方法: 直接上 hub.docker.com 查 ...
- Java基础语法<八> 继承 多态 抽象 反射
1.超类和子类 超类和子类 父类与子类 多态: 一个对象变量可以指示多种实际类型的现象称为多态 一个变量可以引用父类对象,也可以引用其子类对象,这就是多态. 不能将一个超类的引用赋给子类变量,因为调用 ...
- 我所知道的几种display:table-cell的应用
.outer span { display: table-cell; } 一.display:table-cell属性简述 display:table-cell属性指让标签元素以表格单元格的形式呈现 ...
- JQuery EasyUI Layout 在from布局自适应窗口大小
在JQuery EasyUI中,如果直接在form上布局时当窗口大小调整布局不会改变,将布局应用于body时中间隔着一个form,横竖不好弄. 网上有多个解决方案,一般都是写代码,在窗口大小改变时设置 ...
- Understanding Flash: Blocks, Pages and Program / Erases
https://flashdba.com/2014/06/20/understanding-flash-blocks-pages-and-program-erases/ In the last pos ...
- Docker Compose一键部署Nginx反向代理Tomcat集群
目录结构如下 mysql/conf/my.cnf [mysqld] user=mysql port=3306 datadir=/var/lib/mysql socket=/var/lib/mysql/ ...