TabHost无法使用TabSpec中的内容

时间:2014-05-14 09:35:59

标签: android android-tabhost android-tabs fragment-tab-host

我不能在TabSpec项目中做一些东西,例如画廊,当我把按钮和东西他们没有回应我有这个布局有3个标签

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/tabHost1">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:id="@+id/linearLayout1">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <include
                android:layout_width="fill_parent"
                layout="@layout/gallery" />
            <include
                android:layout_width="fill_parent"
                layout="@layout/facebook" />
            <include
                android:layout_width="fill_parent"
                layout="@layout/instagram" />
        </FrameLayout>
    </LinearLayout>
</TabHost>

我有这个片段,但我不知道如何在标签内工作因为我放在SetContent Resource.Id.gallery布局例如不是意图所以我不能参考画廊布局内的东西

using Android.OS;
using Android.Views;
using Android.Widget;

using Fragment = Android.App.Fragment;

namespace sPhotos.Fragments
{
    public class UploadPhotos : Fragment

    {
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
        }

        public static UploadPhotos NewInstance ()
        {
            var frag1 = new UploadPhotos {
                Arguments = new Bundle ()
            };
            return frag1;
        }

        public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate (Resource.Layout.uploadphotos, container, false);
            var tabhost = view.FindViewById<TabHost>(Resource.Id.tabHost1);
            tabhost.Setup();

            var gallery = tabhost.NewTabSpec("gallery");
            gallery.SetContent(Resource.Id.gallery);
            gallery.SetIndicator("Gallery");

            var facebook = tabhost.NewTabSpec("facebook");
            facebook.SetContent(Resource.Id.facebook);

            facebook.SetIndicator("Facebook");

            var instagram = tabhost.NewTabSpec("instagram");
            instagram.SetIndicator("Instagram");
            instagram.SetContent(Resource.Id.instagram);


            tabhost.AddTab(gallery);
            tabhost.AddTab(facebook);
            tabhost.AddTab(instagram);


            return view;
        }
    }


}

0 个答案:

没有答案