title: Null Pointer Exception on an EditText in a Fragment
body: <p>I am building a signUp page in which i want a date picker but whenever i click on User <code>Fragment</code> to open Sign up Page then the app crashes, and the error is <code>nullPointerException</code> in <code>EditText</code>. Please Help me to solve it.</p>
  
  <p>Here is the Code of <code>UserFragment.java</code></p>
  
  <pre><code>public class UserFragment extends Fragment {
  public EditText et_Date;
  public static final int REQUEST_CODE = 11;
  String selectedDate;
  private OnFragmentInteractionListener mListener;
  public DatePickerDialog.OnDateSetListener setListener;
  View view;
  public UserFragment() {
  }
  public static UserFragment newInstance() {
      UserFragment fragment = new UserFragment();
      return fragment;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  }
  @Nullable
  @Override
  public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      view = inflater.inflate(R.layout.adduser_fragment, container, false);
      et_Date  = (EditText) view.findViewById(R.id.etdate);
      final FragmentManager fm = ((AppCompatActivity)getActivity()).getSupportFragmentManager();
      et_Date.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              AppCompatDialogFragment newFragment = new DatePickerFragment();
              newFragment.setTargetFragment(UserFragment.this,REQUEST_CODE);
              newFragment.show(fm, "DatePicker");
          }
      });
      return view;
  }
  
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
      if(requestCode == REQUEST_CODE &amp;&amp; resultCode == Activity.RESULT_OK){
              selectedDate = data.getStringExtra("SelectedDate");
              et_Date.setText(selectedDate);
      }
  }
  
  @Override
  public void onAttach(Context context) {
      super.onAttach(context);
      if(context instanceof OnFragmentInteractionListener){
          mListener= (OnFragmentInteractionListener) context;
      }else{
          throw new RuntimeException(context.toString()+"must implement OnFragmentInterationListener");
      }
  }
  
  @Override
  public void onDetach() {
      super.onDetach();
      mListener = null;
  }
  public interface OnFragmentInteractionListener {
  
      public void onFragmentInteraction(Uri uri);
  }
  }
  </code></pre>