如何在按钮单击时调用容器中的布局(在导航抽屉中)

时间:2016-01-19 09:51:31

标签: android xamarin navigation-drawer

我想在按钮点击时加载布局,如图enter image description here

所示

按钮的点击事件我到这里

 #region OnClick of Account button
        ImageView Account_Button = view.FindViewById<ImageView>(Resource.Id.accountbutton);
        Account_Button.Click += delegate
        {
            //code
        };
        return view;

        #endregion

所以我希望在容器中我想加载一个布局,请建议我怎么做?

1 个答案:

答案 0 :(得分:0)

这是答案

#region OnClick of account button
        ImageView acc_Button = view.FindViewById<ImageView>(Resource.Id.accountbutton_orange);
        acc_Button.Click += delegate
        {
            OnClick();
        };

        #endregion

并致电

public void OnClick()
    {
        FragmentTransaction ft;
        Fragment frag;

        frag = new SlidingTabsFragment();
        ft = FragmentManager.BeginTransaction();
        ft.Replace(Resource.Id.sample_content_fragment, frag);
        ft.AddToBackStack(null);
        ft.Commit();
    }