即使在Android上输入后,TextInput仍保持焦点?

时间:2017-01-07 03:47:13

标签: android react-native react-native-android

我目前正在使用React-Native创建一个简单的应用程序以跟踪美元金额,但是一旦我在输入中输入金额,它就会卡在输入中。一旦我按下Android键盘上的输入/返回键,输入永远不会失去焦点,它甚至进入addAmount函数并打印警告但仍保持光标焦点在输入内,这阻止我再次按r,r刷新应用程序。

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

class AwesomeProject extends Component {
  constructor(props) {
    super(props);
  }
  addAmount(deposit){
    console.warn(deposit);
  }
  render() {
    return (
      <View style={{ flex: 1, flexDirection: 'column'}}>
        <View style={{flex: 1, backgroundColor: 'skyblue', justifyContent:'center'}}>
          <Text>YTD Earnings: $10</Text>          
        </View>
        <View style={{flex: 1, backgroundColor: '#95a5a6'}}>
          <TextInput
          ref = 'amount'
          placeholder='Enter Amount'
          keyboardType='numeric'
          returnKeyType='done'
          onSubmitEditing={(event) => this.addAmount(event.nativeEvent.text)}/>
        </View>
      </View>
    );
  }
}


AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);

0 个答案:

没有答案