Skip to content

Commit 2146139

Browse files
committed
add control listener
1 parent a0b3066 commit 2146139

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

spsedittextview/src/main/java/com/spisoft/spsedittextview/SpsEditText.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import android.speech.RecognitionListener;
1616
import android.speech.RecognizerIntent;
1717
import android.speech.SpeechRecognizer;
18+
import android.text.Editable;
19+
import android.text.TextWatcher;
1820
import android.util.AttributeSet;
1921
import android.util.TypedValue;
2022
import android.view.KeyEvent;
@@ -67,6 +69,7 @@ public class SpsEditText extends RelativeLayout implements RecognitionListener {
6769
private int REQ_CODE_QRCODE = 107;
6870
private boolean UseSpeechToText = true , UseBarcodeScanner = true;
6971
private RelativeLayout ViewBase;
72+
OnChangeTextListener mListener;
7073

7174
public SpsEditText(Context context) {
7275
super(context);
@@ -135,6 +138,24 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
135138
}
136139
});
137140

141+
MText.addTextChangedListener(new TextWatcher() {
142+
@Override
143+
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
144+
145+
}
146+
147+
@Override
148+
public void onTextChanged(CharSequence s, int start, int before, int count) {
149+
150+
}
151+
152+
@Override
153+
public void afterTextChanged(Editable s) {
154+
if(mListener!=null)
155+
mListener.onEvent();
156+
}
157+
});
158+
138159
MBtnQrCode.setOnClickListener(new View.OnClickListener() {
139160
@Override
140161
public void onClick(View v) {
@@ -243,6 +264,14 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
243264
}
244265
//-------------------------------- Function Attributes
245266

267+
public interface OnChangeTextListener {
268+
void onEvent();
269+
}
270+
271+
public void setOnChangeTextListener(OnChangeTextListener eventListener) {
272+
mListener = eventListener;
273+
}
274+
246275
public String GetText(){
247276
return MText.getText().toString();
248277
}

0 commit comments

Comments
 (0)