Click on tabs PagerSlidingTabStrip does not work

709 views Asked by At

I am using https://github.com/astuetz/PagerSlidingTabStrip a navigation drawer(http://androidshenanigans.blogspot.com.es/2015/03/material-design-template.html).

When I put the fragment of the tabs in the navigation fragment I can not click on the tabs. Also, when I add an item to fragment tab.It happens enter image description here

the button is placed on top of the tab.If I do not navigation drawer, it works perfectly.

The code

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>

the code navigation is the template, if you need him, you can ask him http://androidshenanigans.blogspot.com.es/2015/03/material-design-template.html

greetings and thanks!

0

There are 0 answers