单击选项卡PagerSlidingTabStrip不起作用

时间:2015-06-21 16:28:32

标签: android android-fragments click navigation-drawer pagerslidingtabstrip

我正在使用https://github.com/astuetz/PagerSlidingTabStrip导航抽屉(http://androidshenanigans.blogspot.com.es/2015/03/material-design-template.html)。

当我将选项卡的片段放在导航片段中时,我无法单击选项卡。 此外,当我将一个项目添加到片段选项卡时。它发生了 enter image description here

按钮放在标签的顶部。如果我没有导航抽屉,它可以很好地工作。

代码

AdapatadorTabs

public class AdapatadorTabs extends FragmentPagerAdapter {
final int PAGE_COUNT = 2;
private String tabTitles[] = new String[] { "Tab1", "Tab2" };

public AdapatadorTabs(FragmentManager fm) {
    super(fm);
}

@Override
public int getCount() {
    return PAGE_COUNT;
}


@Override
public Fragment getItem(int position) {
    switch (position) {
        case 0:
            return new FragmentTab1();
        case 1:
            return new FragmentTab2();
        default:
            return null;
    }
}

@Override
public CharSequence getPageTitle(int position) {
    // Generate title based on item position
    return tabTitles[position];
}}

FragmentTabGeneral

public class FragmentTabGeneral extends Fragment  {
public static final String ARG_PAGE = "ARG_PAGE";
private ViewPager viewPager;

public FragmentTabGeneral() {
    // Required empty public constructor
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view =  inflater.inflate(R.layout.fragment_telefonos, container, false);
    // Get the ViewPager and set it's PagerAdapter so that it can display items
    viewPager = (ViewPager)view.findViewById(R.id.pager);
    viewPager.setAdapter(new AdapatadorTabs(getChildFragmentManager()));

    // Give the PagerSlidingTabStrip the ViewPager
    PagerSlidingTabStrip tabs = (PagerSlidingTabStrip)view.findViewById(R.id.tabs);
    // Attach the view pager to the tab strip
    tabs.setViewPager(viewPager);
    return view;
}}

FragmentTabGeneral XML

<FrameLayout 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"
android:id="@+id/frameTabs"
tools:context="com.prueba.NavigationDrawer.Fragmentos.FragmentTabGeneral">


<com.astuetz.PagerSlidingTabStrip
    android:id="@+id/tabs"
    android:background="#ffff000c"
    android:textColor="#ffffffff"
    app:pstsIndicatorColor="#ffffffff"
    app:pstsDividerColor="#ffff000c"
    app:pstsIndicatorHeight="2dp"
    app:pstsShouldExpand="true"
    android:layout_width="match_parent"
    android:layout_height="48dip" />

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/tabs"
    tools:context=".MainActivity" /></FrameLayout>

代码导航是模板,如果您需要他,可以问他http://androidshenanigans.blogspot.com.es/2015/03/material-design-template.html

问候和谢谢!

0 个答案:

没有答案