title: Getting ClassCastException in android application
body: <p>When the following activity is launched I a getting <code>ClassCastException</code>. </p>
  
  <p>My Layout:</p>
  
  <pre><code>&lt;android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/pager"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.bhupendra.myapplication.NewDialogsActivity"/&gt;
  </code></pre>
  
  <p>My Activity class:</p>
  
  <pre><code>public class NewDialogsActivity extends ActionBarActivity {
  
      private SectionsPagerAdapter sectionsPagerAdapter;
      private ViewPager viewPager;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          final ActionBar actionBar = getSupportActionBar();
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  
          List&lt;Fragment&gt; tabs = new ArrayList&lt;Fragment&gt;();
          tabs.add(UserFragment.getInstance());
  
          sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), tabs);
  
          viewPager = (ViewPager) findViewById(R.id.pager);
          viewPager.setAdapter(sectionsPagerAdapter);
  
          viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
              @Override
              public void onPageSelected(int position) {
                  actionBar.setSelectedNavigationItem(position);
              }
          });
      }
  
      public static class SectionsPagerAdapter extends FragmentPagerAdapter {
  
          private List&lt;Fragment&gt; fragments;
  
          public SectionsPagerAdapter(FragmentManager fm, List&lt;Fragment&gt; fragments) {
              super(fm);
              this.fragments = fragments;
          }
  
          @Override
          public Fragment getItem(int position) {
              return fragments.get(position);
          }
  
          @Override
          public int getCount() {
              return fragments.size();
          }
  
          @Override
          public CharSequence getPageTitle(int position) {
              return "Users";
          }
      }
  
      @Override
      public void onBackPressed() {
          Intent i = new Intent(NewDialogsActivity.this, DialogsActivity.class);
          startActivity(i);
          finish();
  
      }
  }
  </code></pre>
  
  <p>I have used this theme in my code</p>
  
  <pre><code>&lt;style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"&gt;
      &lt;item name="android:windowNoTitle"&gt;false&lt;/item&gt;
      &lt;item name="android:windowActionBar"&gt;true&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>Logcat</p>
  
  <pre><code>E/AndroidRuntime﹕ FATAL EXCEPTION: main
  java.lang.ClassCastException: android.support.v7.internal.widget.ActionBarOverlayLayout$LayoutParams cannot be cast to com.android.internal.widget.ActionBarOverlayLayout$LayoutParams
          at com.android.internal.widget.ActionBarOverlayLayout.applyInsets(ActionBarOverlayLayout.java:147)
          at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:292)
          at android.view.View.measure(View.java:16030)
          at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5012)
          at android.widget.FrameLayout.onMeasure(FrameLayout.java:314)
          at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2196)
          at android.view.View.measure(View.java:16030)
          at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1915)
          at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1109)
          at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1290)
          at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1009)
          at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5508)
          at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
          at android.view.Choreographer.doCallbacks(Choreographer.java:562)
          at android.view.Choreographer.doFrame(Choreographer.java:532)
          at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
          at android.os.Handler.handleCallback(Handler.java:730)
          at android.os.Handler.dispatchMessage(Handler.java:92)
          at android.os.Looper.loop(Looper.java:213)
          at android.app.ActivityThread.main(ActivityThread.java:5225)
          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:741)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Can somebody help me what is wrong in this code.</p>
  
  <pre><code>minSdk=14
  targetSdk=21
  </code></pre>