Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FragmentManager incompatible with FragmentStatePagerAdapter super constructor

Tags:

android

I am following the Android tutorial. Trying to learn how to use a ViewPager. The problem i am running into is that i am not able to pass the FragmentManager i obtain from Activity to my custom adapter that extends FragmentStatePagerAdapter

Here is some code.

mAdapter = new MyAdapter(getFragmentManager());

and the adapter snippet.

public static class MyAdapter extends FragmentStatePagerAdapter {
    public MyAdapter(FragmentManager fm) {
        super(fm);
    }

I can see the issue is mainly because FragmentStatePagerAdapter is in support.v4 and its expecting a support.v4 version of the FragmentManager. So how do i proceed?

like image 906
DevZer0 Avatar asked Aug 06 '13 10:08

DevZer0


1 Answers

@Flash answered this correctly in the comments, but in case others are searching for an answer, the OP needs to extend FragmentActivity instead of Activity.

like image 189
WEFX Avatar answered Oct 17 '22 02:10

WEFX