Ad
Textview Content That Leads To An Automatic Action
I am using a source code of a Speech-To-Text app (using Google Voice).
I would like to add a code that does the following:
Whenever the content of a TextView shows value X, it leads to an automatic action. And whenever it displays value Y, it leads to a different action.
For instance, the TextView content is read aloud, or the background colour is changed, etc. Not a setOnClickListener, but an automatic action. Thanks in advance!
Ad
Answer
That's so simple check this out:
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
String text = charSequence.toString();
if(text.equalsIgnoreCase("Y")){
//Do your action
}else if(text.equalsIgnoreCase("N")){
//Do your action
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});
Ad
source: stackoverflow.com
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View
Ad