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 Build a Self-Destructing Message Android App Using Fragments for Tabs Modifying Fragments from the Template

Error with the "return new InboxFragment()" method.

'''java @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 new InboxFragment(); '''

The error i am getting is: Incompatible types : Required: android.support.v4.app.fragment, Found: com.example.appname.InboxFragment

1 Answer


I'm guessing that your InboxFragment isn't exending anything at all. Could you try having it extend Fragment (while importing android.support.v4.app.Fragment). Let me know if this helps. If not, could you post your current version of your code(both where the error is found and the InboxFragment). That would help us be able to assist you further.

No need for the code. Apparently there were some imports missing and i misspelled some other things. woops!

Glad you were able to get it working. Good luck with Android development.