Forum Xamarin.Android

View Pager not working with API 19

Hello,
My view pager implementation works fine with API 21 and 23. However when runs on API 19, the tab headings are not clickable and the corresponding toolbar as well. Swiping of the pages worked. Not sure what code to post so I will just post the oncreate method from the activity:

`

    protected override void OnCreate(Bundle bundle){

        base.OnCreate(bundle);

         _fragmentPos = Intent.GetIntExtra("FragmentPos", 0);

        _dbConnection = SQLiteHelper.GetConnection();

            _context = this;

            _masterFragments = new Android.Support.V4.App.Fragment[]
            {
                new ContactsFragment(),
                new MessageFragment(), 
                new CallFragment()
            };

            var titleLabels = CharSequence.ArrayFromStringArray(new[]
            {
                "Contacts",
                "Messages",
                "Calls"
            });

            SetContentView(Resource.Layout.Master); //Set view the Master view

            Toolbar.Toolbar toolbar = FindViewById<Toolbar.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);


            _mViewPager = FindViewById<ViewPager>(Resource.Id.viewPager);
            _mViewPager.Adapter = new MasterAdapter(base.SupportFragmentManager, _masterFragments, titleLabels);

            _mViewPager.SetCurrentItem(_fragmentPos, true);

            TabLayout tabLayout = FindViewById<TabLayout>(Resource.Id.tabs);
            tabLayout.SetupWithViewPager(_mViewPager);

            FloatingActionButton fab = FindViewById<FloatingActionButton>(Resource.Id.fab);
            fab.SetOnClickListener(this);

            ////Create the pageChangeListener class so that the page selected is known
            _pageChangeListener = new MasterPageChangeListener(this, _mViewPager);
            _mViewPager.AddOnPageChangeListener(_pageChangeListener);}`

Let me know what other bit of code to post.

Regards,
Will

Answers

  • mveroukismveroukis CAMember ✭✭✭

    Could you post the .axml file that contains the toolbar, tabs and viewpager? Don't think we need the layout for the viewpager fragments.

  • WilfordMorrisonWilfordMorrison JMUniversity ✭✭

    <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/lib-auto" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context=".MasterActivity"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="8dp" android:theme="@style/AppTheme.AppBarOverlay"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:theme="@style/AppTheme.AppBarOverlay" app:popupTheme="@style/AppTheme.PopupOverlay" app:layout_scrollFlags="scroll|enterAlways" /> <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" /> </android.support.design.widget.AppBarLayout> <android.support.v4.view.ViewPager android:id="@+id/viewPager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behaviour="@string/appbar_scrolling_view_behaviour" /> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="end|bottom" android:layout_margin="16dp" android:src="@android:drawable/ic_dialog_email" /> </android.support.design.widget.CoordinatorLayout>

  • bord81bord81 UAMember

    Did you solve this issue?
    Thanks.

Sign In or Register to comment.