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; 可以 ...
随机推荐
- nmon 加权平均法
Snapshot %tm_act 1 0 2 0 3 0 4 0 5 0 6 6.1 7 6.3 8 6.5 9 9.1 10 5.9 11 0 12 0 13 0 14 0 15 0 (10*0*0 ...
- mybatis 传入多个参数
一.单个参数: public List<XXBean> getXXBeanList(@param("id")String id); <select id=&quo ...
- [TensorBoard] Train and Test accuracy simultaneous tracking
训练时的实时状态跟踪的重要性 不言而喻. [Tensorboard] Cookbook - Tensorboard 讲解调节更新频率 直接上代码展示: import numpy as np impo ...
- iOS 判断App启动方式
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launc ...
- DLL断点调试
一般来说调试DLL是把DLL工程和exe工程放到一个解决方案里.如果不放到一个解决方案里,那两者的输出目录要一致,属性-连接器-常规-输出目录.保证dll,dll的pdb,exe,exe的pdb在一个 ...
- PHP开启伪静态(AppServ服务器)
mod_rewrite是Apache的一个非常强大的功能,它可以实现伪静态页面.下面我详细说说它的使用方法 1.检测Apache是否支持mod_rewrite 通过php提供的phpinfo()函数查 ...
- C++服务器下载文件的两种方式
#include <afxinet.h>#include "wininet.h" #pragma comment( lib, "wininet.lib&quo ...
- hadoop的输入和输出文件
对于hadoop的输入和输出文件,有什么要求吗?
- day_6.23py线程
进程之间不能共享全局变量 线程之间共享全局变量,线程函数中的局部变量不是共享的!! #--*utf- 8*-- from threading import Thread import time g_n ...
- postgresql----聚合函数
聚合函数是从一组输入中计算出一个结果的函数. 测试表 test=# \d tbl_test Table "public.tbl_test" Column | Type | Modi ...