title: setImageDrawble outside onCreate
body: <p>I have drawer layout , and at the top there is an ImageView 
  inside DrawerFragment class ,
  when I tried to setImageDrawble form onCreate it work 
  but when I try to do this method outside onCreat I have ( NUllPointException )
   this is onCreate method </p>
  
  <pre><code>RecyclerView recyclerView ;
  MyAdapter adapter;
  View view ;
  ImageView drawerPic ; 
  private ActionBarDrawerToggle actionBarDrawerToggle ;
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
       view = inflater.inflate(R.layout.drawer_fragmnet_layout,null,false);
  
      recyclerView = (RecyclerView)view.findViewById(R.id.recyclerView);
      adapter = new MyAdapter(getActivity(),setItems());
      recyclerView.setAdapter(adapter);
      recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
  
      drawerPic = (ImageView)view.findViewById(R.id.imageView);
      drawerPic.setImageResource(R.drawable.green);
  
  
      return  view ;
  
  }
  </code></pre>
  
  <p>when I try to do </p>
  
  <pre><code>        drawerPic.setImageResource(R.drawable.green);
  </code></pre>
  
  <p>outside onCreat  (from another method )
  or when I declare object form this class then do another method which setImageResource inside it </p>
  
  <p>,, I have this error   </p>
  
  <blockquote>
    <p>03-22 21:01:30.525 29538-29538/maysara.maysara_.com.materialdesignpro E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                            java.lang.RuntimeException: Unable to start activity ComponentInfo{maysara.maysara_.com.materialdesignpro/maysara.maysara_.com.materialdesignpro.MainActivity}: java.lang.NullPointerException
                                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2356)
                                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2408)
                                                                                                at android.app.ActivityThread.access$600(ActivityThread.java:167)
                                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378)
                                                                                                at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                                                at android.os.Looper.loop(Looper.java:194)
                                                                                                at android.app.ActivityThread.main(ActivityThread.java:5405)
                                                                                                at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                                at java.lang.reflect.Method.invoke(Method.java:525)
                                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:838)
                                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
                                                                                                at dalvik.system.NativeStart.main(Native Method)
                                                                                             Caused by: java.lang.NullPointerException
                                                                                                at maysara.maysara_.com.materialdesignpro.DrawerFragment.setUp(DrawerFragment.java:55)
                                                                                                at maysara.maysara_.com.materialdesignpro.MainActivity.onCreate(MainActivity.java:36)
                                                                                                at android.app.Activity.performCreate(Activity.java:5122)
                                                                                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1151)
                                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2320)
                                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2408) 
                                                                                                at android.app.ActivityThread.access$600(ActivityThread.java:167) 
                                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378) 
                                                                                                at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                                                at android.os.Looper.loop(Looper.java:194) 
                                                                                                at android.app.ActivityThread.main(ActivityThread.java:5405) 
                                                                                                at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                                                at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:838) 
                                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 
                                                                                                at dalvik.system.NativeStart.main(Native Method) </p>
  </blockquote>
  
  <p>why this is happened ? </p>