【原创】东方耀reactnative 视频16,17之-TextInput组件

小米手机遇到通用问题

react-native run-android 运行生成 android|app|build|outputs|apk
生成的apk丢到小米手机上
(用手机qq接收apk)然后安装

文本输入框 TextInput 基本组件,自动补全的search功能
调试apk目录

project|android|app|build|outputs|apk
小米已启用,允许其他应用显示
有可能无法联接到服务器,手机动动,在菜单中的device上配置ip

主要属性和事件如下:
autoCapitalize, : none,sentences words characters,当用户输入时,用于提示
placeholder:占位符,在输入前显示的文本内容
value: 文本输入框的default值
placeholderTextColor:占位符文本色
password: boolean类型,true表示密码输入显示**
multiline:多行输入

btn:{
width:45,
marginLeft:-5,//这个负数很有讲究,比如baidu.com首页那个按钮一定要占用一点才不会显示出缺陷那一块来
marginRight:5,
backgroundColor:’#23BEFF’,
height:45,
justifyContent:’center’,
alignItems:’center’,
},

17 加上自动提示功能

通常,完成此功能要一个search服务,返回n条结果,并将其展示出来,这里我们用静态数据模拟出来

>
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
‘use strict’;

import React, { Component } from ‘react’;
import {
AppRegistry,
StyleSheet,
PixelRatio,
ScrollView,
Text,
TextInput,
View
} from ‘react-native’;

var onePT = 1 / PixelRatio.get();

class demo2 extends Component {
render() {

return (

    <View style={[styles.flex,styles.topStatus]}>

      <Search></Search>

    </View>

);

}
}

class Search extends Component {
constructor(props){
super(props);
this.state = {
show:false,
value:null,
};
}

hide(val){
this.setState(
{
show: false,
value: val,
}
);
}

getValue(text){

  this.setState({
    show: true,
    value: text,
  });

}

render(){
return(



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值