示例#1
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edittext_test);
    tv_output = (TextView) findViewById(R.id.tv_output);
    mCustomEditText = (CustomEditText) findViewById(R.id.customEditText_test);
    mCustomEditText.setOnKeyPreIme(this);
    mCustomEditText.setFilters(new InputFilter[] {new AmountItalyInputFilter()});
    mCustomEditText.setOnEditorActionListener(
        new OnEditorActionListener() {

          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event == null) {
              printLog("onEditorAction is null ,onEditorAction " + actionId);
            } else {
              printLog("onEditorAction:onEditorAction" + actionId + "key:" + event.getKeyCode());
            }
            //                    checkAmountView();
            return false;
          }
        });

    mCustomEditText2 = (CustomEditText) findViewById(R.id.customEditText_test2);
    mCustomEditText3 = (CustomEditText) findViewById(R.id.customEditText_test3);
    mCustomEditText3.setFilters(new InputFilter[] {new AmountItalyInputFilter()});
  }
  private void init() {
    this.mDrawable = this.mContext.getResources().getDrawable(R.drawable.edittext_icon);
    addTextChangedListener(
        new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          @Override
          public void afterTextChanged(Editable s) {
            textChange();
          }
        });
    super.setOnFocusChangeListener(this);
  }