|
15 | 15 | import android.speech.RecognitionListener;
|
16 | 16 | import android.speech.RecognizerIntent;
|
17 | 17 | import android.speech.SpeechRecognizer;
|
| 18 | +import android.text.Editable; |
| 19 | +import android.text.TextWatcher; |
18 | 20 | import android.util.AttributeSet;
|
19 | 21 | import android.util.TypedValue;
|
20 | 22 | import android.view.KeyEvent;
|
@@ -67,6 +69,7 @@ public class SpsEditText extends RelativeLayout implements RecognitionListener {
|
67 | 69 | private int REQ_CODE_QRCODE = 107;
|
68 | 70 | private boolean UseSpeechToText = true , UseBarcodeScanner = true;
|
69 | 71 | private RelativeLayout ViewBase;
|
| 72 | + OnChangeTextListener mListener; |
70 | 73 |
|
71 | 74 | public SpsEditText(Context context) {
|
72 | 75 | super(context);
|
@@ -135,6 +138,24 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
135 | 138 | }
|
136 | 139 | });
|
137 | 140 |
|
| 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 | + |
138 | 159 | MBtnQrCode.setOnClickListener(new View.OnClickListener() {
|
139 | 160 | @Override
|
140 | 161 | public void onClick(View v) {
|
@@ -243,6 +264,14 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
243 | 264 | }
|
244 | 265 | //-------------------------------- Function Attributes
|
245 | 266 |
|
| 267 | + public interface OnChangeTextListener { |
| 268 | + void onEvent(); |
| 269 | + } |
| 270 | + |
| 271 | + public void setOnChangeTextListener(OnChangeTextListener eventListener) { |
| 272 | + mListener = eventListener; |
| 273 | + } |
| 274 | + |
246 | 275 | public String GetText(){
|
247 | 276 | return MText.getText().toString();
|
248 | 277 | }
|
|
0 commit comments