0
votes

Hello friends I'm new to Android Development and Stackoverflow, I'm facing some issues in android layout, I have created two layout folders one for portrait and one for landscape(both for tablet TVDPI)

layout-sw600dp-land-tvdpi & layout-sw600dp-port-tvdpi

The issue I'm facing is when I run my program in portrait mode it shows me correct layout of portrait but when I turn my device portrait to landscape it shows me same layout of portrait, and same case when I run it in landscape mode it run correctly and turn to potrait it shows me the landscape layout...

Why?

1
Hey! Can you paste your manifest.xml code.Shankar
'<manifest xmlns:android="schemas.android.com/apk/res/android" android:installLocation="auto" android:versionName="2.4" package="abc.com" android:versionCode="5"> <uses-sdk android:minSdkVersion="10" /> <application android:label="TMS Tasks" android:icon="@drawable/Icon"> </application> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />'user5680859
This is not complete menifest, It has no activity defined for default launch and all. Anyway if you want to recreate and reload your layout please remove android:configChanges="keyboardHidden|orientation" from your menifest file..Shankar
But there is no android:configChanges="keyboardHidden|orientation in my manifest fileuser5680859
Hi please DO NOT put your code in comments. Just edit your post to put itpiotrek1543

1 Answers

0
votes

Try this

 #region Handle State on Orientation
    //this has been done using better technique
    protected override void OnSaveInstanceState(Bundle outState)
    {
        base.OnSaveInstanceState(outState);
        //adding spinner/dropdownlist selected item
        if (ViewModel.IsLoading == true)
        {
            isLoadingState = true;
            AndroidHUD.AndHUD.Shared.Dismiss(this);
        }
        var preferences = GetSharedPreferences("TmsAppData", FileCreationMode.Private);
        var editor = preferences.Edit();
        //editor.PutString("DeviceId", registrationId);
        editor.PutBoolean("IsOrientationChange", true);
        editor.Commit();
        //outState.PutInt("_AlreadySelectedPostion", _AlreadySelectedPostion);
        outState.PutBoolean("_isLoadingState", isLoadingState);
    }
    protected override void OnRestoreInstanceState(Bundle savedInstanceState)
    {
        base.OnRestoreInstanceState(savedInstanceState);
        //setting a flag to manage spinner selected state
        _IsStateViewActive = true;
        isLoadingState = savedInstanceState.GetBoolean("_isLoadingState");
        if (ViewModel.IsLoading == true)
        {
            isLoadingState = false;
            ViewModel.IsLoading = true;
        }

        //getting the previous selected item from the saved state for spinner / dropdownlist
        //_AlreadySelectedPostion = savedInstanceState.GetInt("_AlreadySelectedPostion");
    }

    #endregion