Skip to content Skip to sidebar Skip to footer

No View Found For Id When Orientation Changes Illegalargumentexception:?

I am creating an application. I have two kinds of view. ThumbView & GridView. For these views I am using two different FragmentStatePagerAdapters for ViewPager. With in the mai

Solution 1:

You can override onConfigurationChanged(...) to handle orientation changes.

Add this line to your <activity > in your mainfest:

android:configChanges="orientation"

Add this method to do what you want when the orientation is changed

@OverridepublicvoidonConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    // Checks the orientation of the screenif (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
    } elseif (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
        Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
    }
}

Post a Comment for "No View Found For Id When Orientation Changes Illegalargumentexception:?"