Hi

I worked around this by forcing orientation (makes no sense to switch in my
project) but I'd still like to get to the bottom of this. My app has an
activity that uses a tab layout that I'm realizing using the actionbar tab
and two fragments.

Here's the fragment related code:

protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            createTabs();
        }

        private void createTabs()
        {
            ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
            ActionBar.Tab myTab = ActionBar.NewTab();
            myTab.SetText(Resource.String.dialer_tab);
            myTab.SetTabListener(this);
            myTab.SetTag(Constants.CALL_CREATION_FRAGMENT);
            //myTab.SetTag(Constants.DIALER_FRAGMENT);
            ActionBar.AddTab(myTab);

            myTab = ActionBar.NewTab();
            myTab.SetText(Resource.String.call_tab);
            myTab.SetTabListener(this);
            myTab.SetTag(Constants.CALLS_FRAGMENT);
            ActionBar.AddTab(myTab);
        }

        /// <summary>
        /// user selected the already existing tab
        /// </summary>
        /// 
        /// 
        public void OnTabReselected(ActionBar.Tab tab, FragmentTransaction
ft)
        {
        }

        public void OnTabSelected(ActionBar.Tab tab, FragmentTransaction ft)
        {
            switch (tab.Tag.ToString())
            {
                case Constants.DIALER_FRAGMENT:
                    Fragment dialerFragment = tabFragments.FirstOrDefault(t
=> t.GetType() == typeof(DialerFragment));
                    if (dialerFragment == null)
                    {
                        dialerFragment = DialerFragment.Instantiate(this,
(new DialerFragment()).Class.Name);
                        ft.Add(Android.Resource.Id.Content, dialerFragment,
typeof(DialerFragment).FullName);
                        tabFragments.Add(dialerFragment);
                    }
                    else
                        ft.Attach(dialerFragment);
                    break;
                case Constants.CALLS_FRAGMENT:
                    Fragment callsFragment = tabFragments.FirstOrDefault(t
=> t.GetType() == typeof(CallsFragment));
                    if (callsFragment == null)
                    {
                        callsFragment = CallsFragment.Instantiate(this, (new
CallsFragment()).Class.Name);
                        ft.Add(Android.Resource.Id.Content, callsFragment,
typeof(CallsFragment).FullName);
                        tabFragments.Add(callsFragment);
                    }
                    else
                        ft.Attach(callsFragment);
                    break;
                case Constants.CALL_CREATION_FRAGMENT:
                    Fragment callCreationFragment =
tabFragments.FirstOrDefault(t => t.GetType() ==
typeof(CallCreationFragment));
                    if (callCreationFragment == null)
                    {
                        callCreationFragment =
CallCreationFragment.Instantiate(this, (new
CallCreationFragment()).Class.Name);
                        ft.Add(Android.Resource.Id.Content,
callCreationFragment, typeof(CallCreationFragment).FullName);
                        tabFragments.Add(callCreationFragment);
                    }
                    else
                        ft.Attach(callCreationFragment);
                    break;
            }
        }

        public void OnTabUnselected(ActionBar.Tab tab, FragmentTransaction
ft)
        {
            switch (tab.Tag.ToString())
            {
                case Constants.DIALER_FRAGMENT:
                    Fragment dialerFragment = tabFragments.FirstOrDefault(t
=> t.GetType() == typeof(DialerFragment));
                    if (dialerFragment != null)
                        ft.Detach(dialerFragment);
                    break;
                case Constants.CALLS_FRAGMENT:
                    Fragment callsFragment = tabFragments.FirstOrDefault(t
=> t.GetType() == typeof(CallsFragment));
                    if (callsFragment != null)
                        ft.Detach(callsFragment);
                    break;
                case Constants.CALL_CREATION_FRAGMENT:
                    Fragment callCreationFragment =
tabFragments.FirstOrDefault(t => t.GetType() ==
typeof(CallCreationFragment));
                    if (callCreationFragment != null)
                        ft.Detach(callCreationFragment);
                    break;
            }
        }

Switching between tabs works fine.

However, if I do this:

Enter the tab activity, change screen rotation by holding the device
differently, change screen rotation back to portrait, then select the calls
tab, the contents of the dialer tab remains visible and the contents of the
calls tab is being put on top. Switching between tabs in this state remains
a mess. The only way to get it back to normal is exiting the activity.

Is there something I'm missing with my fragment transactions?

Regards
Stephan



--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Actionbar-Tab-overlay-issues-tp5711868.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to