Reputation: 99
I have created an app where the user can enter some text and it searches the database once the user presses the search button. I have now modified this so it works with NFC. The NFC tags stores some text (Hello World) and once the tag has been tapped on the phone the text (Hello World) is inserted into the textview. The user can then press the search button and so on.
Is it possible to automatically press the search button once text has been entered into the textbox. For Example, The user taps their phone on the NFC tag, Hello World is entered in the textbox and the search occurs automatically without the user having to press the button.
Is this possible?
Thanks
Upvotes: 0
Views: 218
Reputation: 2737
When user taps their phone on the NFC tag, enter Hello World in the textbox and programmatically click SearchButton using performClick()
.
button.performClick();
Upvotes: 1
Reputation: 1215
Yes it can be by using textwatcher on editext.
SerachEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
if(s.toString().contains("HelloWord Or You unique NFC Text")){
//Enter here Button Pressed Code
}
}
@Override
public void afterTextChanged(Editable arg0) {
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
}
});
Upvotes: 0