title: Get Drawable from image view
body: <p>When I do the clip drawable example described in <a href="http://developer.android.com/guide/topics/resources/drawable-resource.html#Clip" rel="nofollow">this</a> document ImageView.getDrawable always return null. Can anyone pls help me?</p>
  
  <p>In MainActivity.java onCreate</p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          ImageView imageview = (ImageView) findViewById(R.id.image);
          ClipDrawable drawable = (ClipDrawable) imageview.getDrawable();
          drawable.setLevel(drawable.getLevel() + 1000); //Line number 21
      }
  </code></pre>
  
  <p>Logcat</p>
  
  <pre><code> 02-04 12:16:31.156: E/AndroidRuntime(4611): FATAL EXCEPTION: main02-04 12:16:31.156: E/AndroidRuntime(4611): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.test/com.example.test.MainActivity}: java.lang.NullPointerException
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at android.os.Handler.dispatchMessage(Handler.java:99)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at android.os.Looper.loop(Looper.java:123)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at android.app.ActivityThread.main(ActivityThread.java:3683)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at java.lang.reflect.Method.invokeNative(Native Method)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at java.lang.reflect.Method.invoke(Method.java:507)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at dalvik.system.NativeStart.main(Native Method)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611): Caused by: java.lang.NullPointerException
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at com.example.test.MainActivity.onCreate(MainActivity.java:21)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  
  02-04 12:16:31.156: E/AndroidRuntime(4611):      ... 11 more
  </code></pre>