title: NullPointerException Warning on getView() inside onActivityCreated/onStart/onViewCreated method
body: <p>I know <code>getView()</code> might return null inside <code>onCreateView()</code> method, but even if I put the below code inside <code>onActivityCreated()</code>, <code>onStart()</code> or <code>onViewCreated()</code> methods, it still shows the warning about a possible <code>NullPointerException</code> in Android Studio (although my program runs without any issue). How to get rid of this warning?</p>
  
  <p>I am using Fragments.</p>
  
  <p>Code:</p>
  
  <pre><code>datpurchased = (EditText) getView().findViewById(R.id.datepurchased); 
  //datpurchased defined as instance variable in the class
  </code></pre>
  
  <p>Warning:</p>
  
  <blockquote>
    <p>Method invocation 'getView().findViewById(R.id.datepurchased)' may
    produce 'java.lang.NullPointerException'</p>
  </blockquote>