title: How to only execute code on certain API level
body: <p>For instance, this code:</p>
  
  <pre><code>if (Build.VERSION.SDK_INT &gt; Build.VERSION_CODES.GINGERBREAD) {
  
    myCalendarView.setOnDateChangeListener(
      new OnDateChangeListener() {
  
        @Override
        public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
          Toast.makeText
          (
            getApplicationContext(), ""+dayOfMonth, 0
          ).show();        
        }
  
      }
    );
  
  }  
  </code></pre>
  
  <p>Gives error:</p>
  
  <blockquote>
    <p>Description   Resource    Path    Location    Type Call requires API level 11
    (current min is 8):
    android.widget.CalendarView#setOnDateChangeListener   example.java    /example/src/com/example/example    line
    20    Android Lint Problem</p>
  </blockquote>
  
  <p>I understand why I get this error compile-time. But is there any way to mark a source Java class to only be used on certain API level-11? Or surround code blocks with a define/similar so the code is late-bound/jitted only on devices above API level-11? What is the best solution to achieve what I want? (Which is to provide an activity with CalendarView on devices capabile of it.)</p>