android - issues when I use tablayout and viewpager inside fragment -


hi have tablayout , viewpager inside fragment

public class explore : android.support.v4.app.fragment, appcompatactivity     {         private tablayout tablayout;         private viewpager viewpager;         private timebuget timebuget;         private specialactivity specialactivity;         public override void oncreate (bundle savedinstancestate)         {             base.oncreate (savedinstancestate);              // create fragment here         }          public override view oncreateview (layoutinflater inflater, viewgroup container, bundle savedinstancestate)         {             // use return custom view fragment             // return inflater.inflate(resource.layout.yourfragment, container, false);              //return base.oncreateview (inflater, container, savedinstancestate);             return inflater.inflate(resource.layout.explorelayout,container,false);              viewpager = view.findviewbyid<viewpager> (resource.id.viewpagerexplore);             setupviewpager (viewpager);              tablayout = view.findviewbyid<tablayout> (resource.id.sliding_tabsexplore);             tablayout.setupwithviewpager (viewpager);         }          private void inditialfragment()         {             timebuget = new timebuget ();             specialactivity = new specialactivity ();         }         public void setupviewpager(viewpager viewpager)         {             inditialfragment ();             viewpageradapter adapter = new viewpageradapter (supportfragmentmanager);             adapter.addfragment (timebuget, "explore");             adapter.addfragment (specialactivity, "featured");              viewpager.adapter=adapter;         }     } 
  1. classes cannot have multiple base classes.
  2. if don't use appcompatactivity can't use supportfragmentmanager

how solve it?

you have host fragment inside activity, not use both @ same time. after access supportfragmentmanager this:

viewpageradapter adapter = new viewpageradapter ((specialactivity appcompatactivity).supportfragmentmanager); 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo