我希望在onSubmitEditing函数之后再次关注相同的输入。但还没有实现。任何帮助将不胜感激。
这是我的代码:
cabArticleLocal.createOrReplaceTempView("tempTable")
sqlContext.sql("select row_number() over (order by article_id) as id,is_enabled,cab_article,article_id from tempTable")
我知道如何通过按钮或其他输入字段提交。但我不能用相同的输入做到这一点。
答案 0 :(得分:2)
blurOnSubmit={false}
答案 1 :(得分:0)
根据Docs,它声明:
通过原生元素公开的两种方法是
.focus()
和.blur()
,它们会以编程方式聚焦或模糊TextInput
。
因此,这应该有效:
// create your ref object somewhere global
let barcode: Input;
// then this should work
<Input
ref={this.barcode}
style={styles.barcodeInput}
autoFocus={true}
onChangeText={(text) => {
this.setState({barcodeNumber: text});
}}
onSubmitEditing={(event)=> {
this.getResult();
this.barcode.focus();
}}
placeholder='Barcode Number'/>
getResult(){
if ( this.state.barcodeNumber === '021200507878' ){
this.setState({backgroundColor: '#2ecc71', status:'success'});//green
} else {
this.setState({backgroundColor: '#c0392b', status:'error'}); //red
}
this.clearText('barcode');
}
clearText(fieldName) {
this.refs[fieldName].setNativeProps({text: ''});
}