I have an edit text, when I enter something here and tap outside, the focus and the softkey board should hide and change the visibility of a button if the value entered is not empty. If I again enter and change the value of the edit text 0 and tap out, the button should become invisible again. PFA what I'm doing:
public void onFocusChange(View v, boolean hasFocus) {
String s = enter_num.getText().toString();
if(!(s.equals(""))){
enter_num.setFocusable(isFinishing());
InputMethodManager imm = (InputMethodManager).getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
ans_status2.setVisibility(View.VISIBLE);
}
}
This is not losing the focus. Is this the right approach to start with?