title: Making imageview invisible causes NullPointerException
body: <p>I am running the following code and it gives me NullPointerException in the line iv4.setVisibility(View.INVISIBLE)
   Please suggest. Thanks
  Code:  </p>
  
  <pre><code>ImageView iv4;
      public void onCreate(Bundle savedInstanceState) {
              requestWindowFeature(Window.FEATURE_NO_TITLE);
              getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
              WindowManager.LayoutParams.FLAG_FULLSCREEN);
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_score);
              iv4= (ImageView) findViewById(R.id.imageView4);
              iv4.setVisibility(View.INVISIBLE);
          }
  
  &lt;RelativeLayout 
     xmlns:android="schemas.android.com/apk/res/android"; 
     android:id="@+id/RelativeLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"&gt; 
  
   &lt;ImageView android:id="@+id/imageView4" 
        android:layout_width="110dp" 
        android:layout_height="110dp" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentTop="true" 
        android:src="@drawable/hg" /&gt; 
    &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>The stack trace is as follows:</p>
  
  <pre><code>03-05 03:49:25.477: E/AndroidRuntime(1070): FATAL EXCEPTION: main
  03-05 03:49:25.477: E/AndroidRuntime(1070): java.lang.RuntimeException: Unable to start activity ComponentInfo{bitcream.candyhive.candy/bitcream.candyhive.candy.ScoreActivity}: java.lang.NullPointerException
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at android.os.Handler.dispatchMessage(Handler.java:99)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at android.os.Looper.loop(Looper.java:123)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at android.app.ActivityThread.main(ActivityThread.java:3683)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at java.lang.reflect.Method.invokeNative(Native Method)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at java.lang.reflect.Method.invoke(Method.java:507)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at dalvik.system.NativeStart.main(Native Method)
  03-05 03:49:25.477: E/AndroidRuntime(1070): Caused by: java.lang.NullPointerException
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at bitcream.candyhive.candy.ScoreActivity.onCreate(ScoreActivity.java:42)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  03-05 03:49:25.477: E/AndroidRuntime(1070):     ... 11 more
  03-05 03:49:28.297: I/Process(1070): Sending signal. PID: 1070 SIG: 9
  </code></pre>