导致自动操作的文本视图内容
textview content that leads to an automatic action
我正在使用 Speech-To-Text 应用程序的源代码(使用 Google 语音)。
我想添加执行以下操作的代码:
只要 TextView 的内容显示值 X,就会导致自动操作。每当它显示值 Y 时,它都会导致不同的操作。
比如朗读TextView内容,或者改变背景颜色等,不是setOnClickListener,而是自动动作。提前致谢!
这很简单,看看这个:
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) {
}
});
我正在使用 Speech-To-Text 应用程序的源代码(使用 Google 语音)。
我想添加执行以下操作的代码:
只要 TextView 的内容显示值 X,就会导致自动操作。每当它显示值 Y 时,它都会导致不同的操作。
比如朗读TextView内容,或者改变背景颜色等,不是setOnClickListener,而是自动动作。提前致谢!
这很简单,看看这个:
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) {
}
});