Layout:
<?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp" /> </LinearLayout> </TabHost>
Activity (to be inherited from TabActivity):
Create CreateTab method
private void CreateTab(Type activityType, string tag, string label, int drawableId) { var intent = new Intent(this, activityType); intent.AddFlags(ActivityFlags.NewTask); var spec = TabHost.NewTabSpec(tag); var drawableIcon = Resources.GetDrawable(drawableId); spec.SetIndicator(label, drawableIcon); spec.SetContent(intent); TabHost.AddTab(spec); }
Create two Tab
CreateTab(typeof(BusinessSearch), "Search", "Search", Resource.Drawable.abc_ab_share_pack_mtrl_alpha); CreateTab(typeof(MyOrders), "My Orders", "My Orders", Resource.Drawable.abc_btn_check_material);
The above is C# + Xamarin develops Android applications---Tab implementation content. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!