示例#1
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.TEditorActivity);

            _topToolBar       = FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.TopToolbar);
            _topToolBar.Title = CrossTEditor.PageTitle;
            _topToolBar.InflateMenu(Resource.Menu.TopToolbarMenu);
            _topToolBar.MenuItemClick += async(sender, e) =>
            {
                if (SetOutput != null)
                {
                    if (e.Item.TitleFormatted.ToString() == "Save")
                    {
                        string html = await _editorWebView.GetHTML();

                        SetOutput.Invoke(true, html);
                    }
                    else
                    {
                        SetOutput.Invoke(false, null);
                    }
                }
                Finish();
            };

            _rootLayout    = FindViewById <LinearLayoutDetectsSoftKeyboard>(Resource.Id.RootRelativeLayout);
            _editorWebView = FindViewById <TEditorWebView>(Resource.Id.EditorWebView);
            _toolbarLayout = FindViewById <LinearLayout>(Resource.Id.ToolbarLayout);

            _rootLayout.onKeyboardShown += HandleSoftKeyboardShwon;
            _editorWebView.SetOnCreateContextMenuListener(this);

            BuildToolbar();

            string htmlString = Intent.GetStringExtra("HTMLString") ?? "<p></p>";

            _editorWebView.SetHTML(htmlString);

            bool autoFocusInput = Intent.GetBooleanExtra("AutoFocusInput", false);

            _editorWebView.SetAutoFocusInput(autoFocusInput);
        }
示例#2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);
            mRecyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            AndroidX.AppCompat.Widget.Toolbar toolbar = FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.toolbar);
            toolbar.InflateMenu(Resource.Menu.main);
            toolbar.SetOnMenuItemClickListener(this);
            mRecyclerView.SetLayoutManager(new LinearLayoutManager(this));
            mRecyclerView.HasFixedSize = (true);

            if (savedInstanceState == null)
            {
                mHorizontal = true;
            }
            else
            {
                mHorizontal = savedInstanceState.GetBoolean(ORIENTATION);
            }

            SetupAdapter();
        }