@Override
@Hide
public void innerInitialize(final BA ba, final String eventName, boolean keepOldObject) {
super.ba = ba;
if (!keepOldObject)
setObject(new EditText(ba.context));
super.innerInitialize(ba, eventName, true);
if (ba.subExists(eventName + "_textchanged")) {
TextWatcher watcher = new TextWatcher() {
private CharSequence old;
@Override
public void afterTextChanged(Editable s) {
ba.raiseEvent2(getObject(), false, eventName + "_textchanged", true,
old, getObject().getText().toString());
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
old = s.toString();
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
}
};
getObject().addTextChangedListener(watcher);
}
if (ba.subExists(eventName + "_enterpressed")) {
OnEditorActionListener o = new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
ba.raiseEvent(getObject(), eventName + "_enterpressed");
return false;
}
};
getObject().setOnEditorActionListener(o);
}
if (ba.subExists(eventName + "_focuschanged")) {
getObject().setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
ba.raiseEventFromUI(getObject(), eventName + "_focuschanged", hasFocus);
}
});
}
}