title: Make EditText pass focus back to parent layout when finished editing.
body: <p>I have a linear layout in a fragment with a bunch of checkboxes and various edittext widgets inside it. Basically like a quiz. A bunch of multiple choice(checkboxes) and a dozen short answer(edittexts) questions. </p>
  
  <p>What I would like is for users to be able to click an edittext, type in an answer, then press DONE or click anywhere else on the layout and have the widget lose focus and the keyboard hide. Currently I am overriding the <code>setOnEditorActionListener</code> and <code>setOnFocusChangeListener</code> methods of each edittext to give focus back to a main layout, and hide the keyboard respectively. Here is the code for an edittext instance called "input_7d":</p>
  
  <pre><code>    final EditText input_7d = (EditText) thisview.findViewById(R.id.txtinput_7d);
      final LinearLayout parentLayout = (LinearLayout) thisview.findViewById(R.id.main_layout);
  
      input_7d.setOnEditorActionListener(new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
              if(actionId == EditorInfo.IME_ACTION_DONE) {
                  parentLayout.requestFocus();
              }
              return false;
          }
      });
  
      input_7d.setOnFocusChangeListener(new TextView.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
              if(!hasFocus){
                  InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                  imm.hideSoftInputFromWindow(parentLayout.getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
              }
          }
      });
  </code></pre>
  
  <p>This is annoying to do for every edittext I add, and it means editing lots of code if I remove them or add more in the future. What I would like to do is have a custom edittext class that can return focus to it's parent view/layout and hide the keyboard, then use that instead of the built in edittext. I'm very new to this and I haven't been able to find a way for a custom edittext to pass focus back to it's parent layout. Is there a better way to get a bunch of edittexts to all have this behavior and not have it all "hardcoded" into my fragment class?</p>