コード例 #1
0
ファイル: MainActivity.cs プロジェクト: smeoow/Naive
        private void ReplaceFragment(MyBaseFragment frag)
        {
            DebugEvent("ReplaceFragment");
            var fm = SupportFragmentManager;

            fm.BeginTransaction()
            .SetTransition(FragmentTransaction.TransitFragmentOpen)
            .Replace(R.Id.flContent, frag)
            .Commit();
            curFrag = frag;
        }
コード例 #2
0
ファイル: MainActivity.cs プロジェクト: smeoow/Naive
        private void onNavigationItemSelected(IMenuItem menuItem)
        {
            if (menuItem.IsChecked)
            {
                drawer.CloseDrawers();
                return;
            }
            MyBaseFragment frag   = null;
            int            itemId = menuItem.ItemId;

            switch (itemId)
            {
            case R.Id.nav_home:
                frag = new FragmentHome();
                break;

            case R.Id.nav_logs:
                frag = new FragmentLogs();
                break;

            case R.Id.nav_connections:
                frag = new FragmentConnections();
                break;

            case R.Id.nav_adapters:
                frag = new FragmentAdapters();
                break;

            case R.Id.nav_console:
                frag = new FragmentConsole();
                break;

            case R.Id.nav_start:
                startService();
                break;

            case R.Id.nav_stop:
                stopService();
                break;

            case R.Id.nav_reload:
                reloadService(false);
                break;
            }
            if (frag != null)
            {
                var    title          = itemId == R.Id.nav_home ? JavaAppName : menuItem.TitleFormatted;
                string titleClrString = null;
                SetTitle(title);
                frag.InfoStrChanged += (str) => {
                    if (str == null)
                    {
                        SetTitle(title);
                    }
                    else
                    {
                        if (titleClrString == null)
                        {
                            titleClrString = title.ToString();
                        }
                        SetTitle(titleClrString + " " + str);
                    }
                };

                ReplaceFragment(frag);

                menuItem.SetChecked(true);
            }
            drawer.CloseDrawers();
        }