Hello geas, on this occasion I want to try to share a unique experience when completing a special client project. At that time I was making a validation form where there was one field whose input had to be the nominal value of Indonesian money, where there had to be a dot separator in every thousand. Therefore I need to listen to where the cursor is focused, to be able to activate or disable certain components while formatting the nominal value of money.
Solution
It turns out I need to use the interface OnFocusChangeListener()
and then TODO SOMETHING or do something in its override like onFocusChange
, like the example below.
for (EditText view : editList){
view.setOnFocusChangeListener(focusListener);
}
....
private OnFocusChangeListener focusListener = new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus){
focusedView = v;
} else {
focusedView = null;
}
}
}