To hide the keyboard view programmatically, call this function

public static void hideKeyboard(Context context, View view){
    InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}