TabLayout选项卡可以';不要点击Android

TabLayout选项卡可以';不要点击Android,android,android-tablayout,Android,Android Tablayout,我无法在TabLayout中单击tab。我有两个标签(Genel和Ozel)。当我打开应用程序genel open时,我在genel选项卡中滑动Ozel布局打开。我无法在Ozel选项卡中单击。代码如下所示 XML代码: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" x

我无法在TabLayout中单击tab。我有两个标签(Genel和Ozel)。当我打开应用程序genel open时,我在genel选项卡中滑动Ozel布局打开。我无法在Ozel选项卡中单击。代码如下所示

XML代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

    <android.support.v7.widget.Toolbar
            android:id="@+id/fotogpsbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="?attr/actionBarSize"
            android:theme="?attr/actionBarTheme"
    />

    <android.support.design.widget.TabLayout
        android:id="@+id/fotogpslayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabGravity="fill"
        app:tabMode="fixed"

    >

        <android.support.design.widget.TabItem
                android:id="@+id/fotogpsgenel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Genel"
        />

        <android.support.design.widget.TabItem
            android:id="@+id/fotogpsozel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Özel"
        />

    </android.support.design.widget.TabLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/ogesayfa"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
    >

    </android.support.v4.view.ViewPager>

</RelativeLayout>
Java代码(sayfaadapter-Adapter):

我怎样才能解决这个问题

我需要你的帮助


不是:我希望你能理解。我的英语不好。你可以问你哪里不懂。

你忘了在你的视图中添加下面的
layout\u,所以viewpager覆盖在选项卡上,因此你不能点击选项卡,
在xml中替换如下代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.v7.widget.Toolbar
        android:id="@+id/fotogpsbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        android:theme="?attr/actionBarTheme" />

    <android.support.design.widget.TabLayout
        android:id="@+id/fotogpslayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/fotogpsbar"
        app:tabGravity="fill"
        app:tabMode="fixed">

        <android.support.design.widget.TabItem
            android:id="@+id/fotogpsgenel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Genel" />

        <android.support.design.widget.TabItem
            android:id="@+id/fotogpsozel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Özel" />

    </android.support.design.widget.TabLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/ogesayfa"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/fotogpslayout" />
</RelativeLayout>

public class sayfaadapter extends FragmentPagerAdapter {

    private int tabsayi;

    sayfaadapter(FragmentManager fm, int tabsayi){
        super(fm);
        this.tabsayi = tabsayi;
    }

    @Override
    public Fragment getItem(int i) {

        switch(i){
            case 0:
                return new genel();
            case 1:
                return new ozel();
            default:
                return null;
        }

    }

    @Override
    public int getCount() {
        return tabsayi;
    }
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <android.support.v7.widget.Toolbar
        android:id="@+id/fotogpsbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        android:theme="?attr/actionBarTheme" />

    <android.support.design.widget.TabLayout
        android:id="@+id/fotogpslayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/fotogpsbar"
        app:tabGravity="fill"
        app:tabMode="fixed">

        <android.support.design.widget.TabItem
            android:id="@+id/fotogpsgenel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Genel" />

        <android.support.design.widget.TabItem
            android:id="@+id/fotogpsozel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Özel" />

    </android.support.design.widget.TabLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/ogesayfa"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/fotogpslayout" />
</RelativeLayout>