This is really strange, yesterday I asked the Yesterdays question how to implement multiple editText listeners to avoid duplication of my code. I was kindly provided with the answer (to which I swear I tried), but today I do not get any relation with him. I try to do the following, but when I try to tweak tw Textwatcher I get Cannot instantiate the type TextWatcher .
**TextWatcher tw = new TextWatcher();** intTextValue.addTextChangedListener(tw);
Any help would be greatly appreciated. its beginning confused me a little.
I end up trying to move on to the next situation (what should be just right?).
public class myClass extends Activity implements OnFocusChangeListener, TextWatcher { private EditText et; private EditText et1; private EditText et2; private int whoHasFocus= 0; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout1); et = (EditText)findViewById(R.id.et); et.setOnFocusChangeListener(this); et.addTextChangedListener(tw); et1 = (EditText)findViewById(R.id.et); et1.setOnFocusChangeListener(this); et1.addTextChangedListener(tw); et2 = (EditText)findViewById(R.id.et); et2.setOnFocusChangeListener(this); et2.addTextChangedListener(tw); } @Override public void onFocusChange(View v, boolean hasFocus) { switch (v.getId()) { case R.id.et: whoHasFocus =1; break; case R.id.et1: whoHasFocus =2; break; case R.id.et2: whoHasFocus=3; break; } } @Override public void afterTextChanged(Editable s) { switch (whoHasFocus) { case 1:
source share