protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); ////初始化fragment图标大小 //Drawable drawableChat = GetDrawable(Resource.Drawable.tab_menu_icon); //drawableChat.SetBounds(5, 5, 40, 40);//图标距离左5,上5,宽40,高40 //tab_recharge.SetCompoundDrawables(null, drawableChat, null, null);//图标放在上部 //Drawable icon = GetDrawable(Resource.Drawable.tab_menu_user); ////setBounds(left,top,right,bottom)里的参数从左到右分别是 ////drawable的左边到textview左边缘+padding的距离,drawable的上边离textview上边缘+padding的距离 ////drawable的右边边离textview左边缘+padding的距离,drawable的下边离textview上边缘+padding的距离 ////所以right-left = drawable的宽,top - bottom = drawable的高 //icon.SetBounds(0, 0, 40, 44); //tab_recharge.SetCompoundDrawables(icon, null, null, null); //初始化fragment ly_content = (FrameLayout)FindViewById(Resource.Id.ly_content); MyFragment fg = new MyFragment("第一个fragment"); tab_recharge = (TextView)FindViewById(Resource.Id.tab_recharge); tab_openccard = (TextView)FindViewById(Resource.Id.tab_openccard); tab_personal = (TextView)FindViewById(Resource.Id.tab_personal); bindViews(); tab_recharge.PerformClick(); }
/** * Create a new instance of MyFragment that will be initialized * with the given arguments. */ internal static MyFragment NewInstance(ICharSequence label) { MyFragment f = new MyFragment(); Bundle b = new Bundle(); b.PutCharSequence("label", label); f.SetArguments(b); return f; }
//单击事件 public void onClick(View v) { FragmentTransaction fTransaction = FragmentManager.BeginTransaction(); hideAllFragment(fTransaction); switch (v.Id) { case Resource.Id.tab_recharge: setSelected(); tab_recharge.Selected = true; if (fg1 == null) { fg1 = new MyFragment("开卡Fragment"); fTransaction.Add(Resource.Id.ly_content, fg1); } else { fTransaction.Show(fg1); } break; case Resource.Id.tab_openccard: setSelected(); tab_openccard.Selected = true; if (fg2 == null) { fg2 = new OpenCardFragment(); fTransaction.Add(Resource.Id.ly_content, fg2); } else { fTransaction.Show(fg2); } break; case Resource.Id.tab_personal: setSelected(); tab_personal.Selected = true; if (personalFragment == null) { personalFragment = new PersonalFragment(); fTransaction.Add(Resource.Id.ly_content, personalFragment); } else { fTransaction.Show(personalFragment); } break; } fTransaction.Commit(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(R.Layouts.fragment_arguments_support); if (savedInstanceState == null) { // First-time init; create fragment to embed in activity. FragmentTransaction ft = GetSupportFragmentManager().BeginTransaction(); Fragment newFragment = MyFragment.NewInstance("From Arguments"); ft.Add(R.Ids.created, newFragment); ft.Commit(); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView(Resource.Layout.fragment_arguments_support); if (bundle == null) { // First-time init; create fragment to embed in activity. FragmentTransaction ft = SupportFragmentManager.BeginTransaction(); var newFragment = new MyFragment("From Arguments"); ft.Add(Resource.Id.created, newFragment); ft.Commit(); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.fragment_arguments_support); if (bundle == null) { // First-time init; create fragment to embed in activity. FragmentTransaction ft = SupportFragmentManager.BeginTransaction(); var newFragment = new MyFragment("From Arguments"); ft.Add(Resource.Id.created, newFragment); ft.Commit(); } }
public MyClass(MyFragment fr) { m_proc = new MyProc(); m_frag = new MyFrag(); m_frag.ProcEx(m_proc); }