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 Relating Users in Parse.com Executing a Query

Error: "Your content must have a ListView ... "

HI all,

The app runs but then crashes as I hit the Edit Friends item in the menu.

LogCat says "Your content must have a ListView whose id attribute is 'android.R.id.list' "

This error points at the line setContentView(R.layout.activity_edit_friends);

That XML file doesn't have the ListView in it; that's in fragment_edit_friends.xml.

The fragment XML has a Relative Layout but the Activity XML is a FrameLayout. I've tried copying the <ListView> paragraph across but that wouldn't save.

Any thoughts on what I'm trying to achieve here; my xml knowledge isn't great.

Thanks,

Steve.

2 Answers

Nick Edwards
PLUS
Nick Edwards
Courses Plus Student 15,766 Points

Hi Steve,

Could you post the contents of your xml files (both the activity and fragment) and the associated Java file? It sounds like the app is trying to pull data from the wrong xml file - the ListView should indeed be in the fragment as the only purpose of the activity is to display the fragment.

Hi Nick,

Unfortunately, I've been messing about with the files and my Git hasn't allowed me to revert to where I was. Not sure why!

So, I'll go back a couple of steps and redo the lessons; it'll only take half an hour to get to where I was. If I get the same error again, I'll let you know! But if I do it wrong twice, I need to have a word with myself!

Steve.