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; } }
- classes cannot have multiple base classes.
- 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);