C# tabhost未在xamarin中显示选项卡
选项卡栏不工作C# tabhost未在xamarin中显示选项卡,c#,xamarin.android,xamarin,C#,Xamarin.android,Xamarin,选项卡栏不工作 <?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"> &l
<?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">
<RelativeLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true">
<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:layout_above="@android:id/tabs" />
</RelativeLayout>
</TabHost>
请帮助,谢谢。我看不到您在哪里分配了
TabHost
。在上面的代码中,我分配了TabHost,您没有TabHost
分配,比如TabHost=blablabla代码>任何地方。如果在任何演练中仔细查看,您必须使用TabActivity
来获取您必须使用的代码片段。
public class tab_content : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.tabmenu);
TabHost.TabSpec spec;
Intent intent;
intent = new Intent (this, typeof (rate1));
intent.AddFlags (ActivityFlags.NewTask);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = TabHost.NewTabSpec ("tab1");
spec.SetIndicator ("Check In", Resources.GetDrawable (Resource.Drawable.ic_tab_artists));
spec.SetContent (intent);
TabHost.AddTab (spec);
// Do the same for the other tabs
intent = new Intent (this, typeof (rate2));
intent.AddFlags (ActivityFlags.NewTask);
spec = TabHost.NewTabSpec ("tab2");
spec.SetIndicator ("Guest Room", Resources.GetDrawable (Resource.Drawable.ic_tab_artists));
spec.SetContent (intent);
TabHost.AddTab (spec);
intent = new Intent (this, typeof ( rate3));
intent.AddFlags (ActivityFlags.NewTask);
spec = TabHost.NewTabSpec ("tab3");
spec.SetIndicator ("Laundry and Valet", Resources.GetDrawable (Resource.Drawable.ic_tab_artists));
spec.SetContent (intent);
TabHost.AddTab (spec);
TabHost.CurrentTab = 0;
}
}