0

I'm trying to put a viewpager in a custom dialog (wasabeef's blurdialogfragment) but, I don't whats the problems, or how to replace it, because it's says: "cannot resolve method getSupportFragmentManager()"

If anyone can help me with this, i would be thankful..

Code:

 public class DialogHelperForNoobs extends BlurDialogFragment {

    String personName;
    String personGivenName;
    String personFamilyName;
    String personEmail;
    String personId;


    private SectionsPagerAdapter mSectionsPagerAdapter;

    private ViewPager mViewPager;

    public DialogHelperForNoobs() {
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return createDialogHelperForNoobs();
    }

    public AlertDialog createDialogHelperForNoobs() {

        Bundle mArgs = getArguments();

        //Datos Usuario
        personName = mArgs.getString("personName");
        personGivenName = mArgs.getString("personGivenName");
        personFamilyName = mArgs.getString("personFamilyName");
        personEmail = mArgs.getString("personEmail");
        personId = mArgs.getString("personId");

        //INFLADOR DIALOGO
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        LayoutInflater inflater = getActivity().getLayoutInflater();
        View v = inflater.inflate(R.layout.activity_dialog_helper_for_noobs, null);

        //Error in FragmentManager getSupportFragmentManager()
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

        // Set up the ViewPager with the sections adapter.
        mViewPager = (ViewPager) v.findViewById(R.id.ViewPager);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        builder.setView(v);




        return builder.create();
    }


    public static class PlaceholderFragment extends Fragment {
        /**
         * The fragment argument representing the section number for this
         * fragment.
         */
        private static final String ARG_SECTION_NUMBER = "section_number";

        public PlaceholderFragment() {
        }

        /**
         * Returns a new instance of this fragment for the given section
         * number.
         */
        public static PlaceholderFragment newInstance(int sectionNumber) {
            PlaceholderFragment fragment = new PlaceholderFragment();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            fragment.setArguments(args);
            return fragment;
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_view_pager_noobs, container, false);
            TextView textView = (TextView) rootView.findViewById(R.id.section_label);
            textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
            return rootView;
        }
    }

    public class SectionsPagerAdapter extends FragmentPagerAdapter {

        public SectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            // getItem is called to instantiate the fragment for the given page.
            // Return a PlaceholderFragment (defined as a static inner class below).
            return PlaceholderFragment.newInstance(position + 1);
        }

        @Override
        public int getCount() {
            // Show 3 total pages.
            return 3;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch (position) {
                case 0:
                    return "SECTION 1";
                case 1:
                    return "SECTION 2";
                case 2:
                    return "SECTION 3";
            }
            return null;
        }
    }

}

Anyone can help? Thanks.

Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95

1 Answers1

0

Depends where you are calling it from but I suspect it is because you are calling this from the fragment when getSupportFragmentManager is a method on the AppCompatActivity class

Kuffs
  • 35,581
  • 10
  • 79
  • 92