Textinput onpress动作移动下一部分

时间:2017-06-24 08:46:58

标签: javascript android reactjs react-native

我正在为我的应用程序和登录屏幕工作,我希望用户从中移动 当用户按下username-textinput按钮时,password-textinputenter

class Login extends Component {  
    constructor(){ 
        super();        
        this.state = {
            username : "",
            password: "",
            isLoading : false       }   }

    render() {          

        return (
                 <View>

                    <TextInput
                        placeholder="Username"
                        onChangeText={ (text)=> this.setState({username: text}) }
                        autoCorrect = {false}                   
                    />
                    <TextInput
                        secureTextEntry={true}
                        placeholder="Password"
                        onChangeText={ (text)=> this.setState({password: text}) }

                    />
                 </View>
                );    } }

我怎样才能做到这一点?我使用React-native

2 个答案:

答案 0 :(得分:1)

这是一个解决方案

                <TextInput
                    placeholder="Username"
                    ref={(input)=> this.username=input}
                    onSubmitEditing={() => this.password.focus()}
                    onChangeText={ (text)=> this.setState({username: text}) } 
                    autoCorrect = {false}                   
                />
                <TextInput
                    secureTextEntry={true}
                    placeholder="Password"
                    ref={(input)=>this.password=input}
                    onChangeText={ (text)=> this.setState({password: text}) }

                />
             </View>

答案 1 :(得分:0)

我认为React-native不支持imeiOptions,因此您可以尝试在textinputs中设置multiline=false

React Native TextInput