Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

error: no suitable method found for show(android.app.FragmentManager,String)

Error:(62, 31) error: no suitable method found for show(android.app.FragmentManager,String)
method DialogFragment.show(FragmentTransaction,String) is not applicable
(actual argument android.app.FragmentManager cannot be converted to FragmentTransaction by method invocation conversion)
method DialogFragment.show(android.support.v4.app.FragmentManager,String) is not applicable
(actual argument android.app.FragmentManager cannot be converted to android.support.v4.app.FragmentManager by method invocation conversion)

This Error occured when I tried to run the following code.

private void alertUserAboutError() {
                alertDialogFragment dialogFragment = new alertDialogFragment();
                dialogFragment.show(getFragmentManager(),"error_dialog");
            }

How do I fix this error?

1 Answer

J.D. Sandifer
J.D. Sandifer
18,813 Points

If the support library link from Simon didn't lead you to a solution, you might try adding .beginTransaction() onto .getFragmentManager() to use the transaction version of the show method.

If you could post a link to the problem in the comments I can probably help you more.

(And if you already found a different solution to the problem, please post it as an answer to your question so everyone else can benefit from what you learned. And don't forget to mark it as an answer so everyone knows the question has been answered.)