以下内容全部或部分转自或参考于网络。
Android3.0之后推荐使用ActionBar,Android5.0后替换为ToolBar(但没有Tab项)
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
//TextView tvUserName = (TextView)FindViewById(Resource.Id.tvUserName);
从意图中获取传递过来的参数——账号
//tvUserName.Text = Intent.Extras.GetString("userName");
var tab1 = ActionBar.NewTab();
tab1.SetText("Tab1");
tab1.SetIcon(Resource.Drawable.Icon);
tab1.TabSelected += (s, e) =>
{
};
ActionBar.AddTab(tab1);
var tab2 = ActionBar.NewTab();
tab2.SetText("Tab2");
tab2.SetIcon(Resource.Drawable.Icon);
tab2.TabSelected += (s, e) =>
{
};
ActionBar.AddTab(tab2);
}