Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.