Skip to content Skip to sidebar Skip to footer

ClasscastException When Casting To ViewPager

I am trying to create an application based on the new ViewPager from the compability library. When I copy the lines from the sample application: setContentView(R.layout.main); MyAd

Solution 1:

Actually the problem ist the old layout inflating problem (look here). For some magic reasons findViewByID doesn't return null here. Instead of returning null it returns a android.support.v4.app.NoSaveStateFrameLayout which is very funny btw.


Solution 2:

Class cast exceptions occur when you try to cast an object to type which is not compatible with it. So please check whether ViewPager instantiation you are doing is correct or not.


Post a Comment for "ClasscastException When Casting To ViewPager"