I know that TextInput's native text has an onsubmit callback function, but how can I make this submit button?

I would like to know how to draw this button, and if so, is it automatically bound to the text in the input field?

+5
source share
3 answers

Basically onSumbitEditing will display a onSumbitEditing event when you press the go button on the Android keyboard, as shown below:

  <TextInput style={[styles.zipCode, styles.mainText]} returnKeyType='My Custom button' onSubmitEditing={(event) => this.updateText( event.nativeEvent.text )}/> 

in the code snippet above: I have the name of the action - this is β€œMy custom button”, which will appera on the soft keyboard in Android and when you click on the updateText event is triggered, here's what the value of onSubmitEditing is

Note: if the physical keyboard is enabled in the android emulator, therefore, onSubmitEditing will not tiger any event, since you will also not need to press a virtual key called the name "My custom button"

+18
source

The onSubmit callback is called when you press the done / return / join button on the keyboard that appears

+1
source

You might have something like this:

 onSubmitEdit = () => { // whatever you want to do on submit } render() { return( <View> <TextInput style={styles.input} textAlign="center" onSubmitEditing={this.submitEdit} /> <TouchableHighlight onPress={this.onSubmitEdit}> <Text>Press this button to submit editing</Text> </TouchableHighlight> </View> ); } 
+1
source

Source: https://habr.com/ru/post/1237082/


All Articles