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

David Emelianov
David Emelianov
3,778 Points

Ribbit crashes when "edit friends" is selected

When I select "Edit friends" from the menu, the app crashes. LogCat says "your content must have ListView whose id attribute is 'android.R.id.list'". I've replaced each of my .java files with the project files posted with the video - none resolve the error. Anyone else experiencing this issue?

In layout/activity_edit_friends.xml, try changing android:id property to android:id="@android:id/list"

4 Answers

Cameron Stewart
Cameron Stewart
18,041 Points

I am also having the smae error. I changed the array adapter rrayAdapter<String> adapter = new ArrayAdapter<String>(EditFriendsActivity.this, android.R.layout.simple_list_item_checked, usernames);

to

rrayAdapter<String> adapter = new ArrayAdapter<String>(EditFriendsActivity.this, android.R.id.list, usernames);

no change in outcome.

Help please

What I did to fix the solution was to add a ListView to activity_edit_friends.xml. I just copied the same one from the fragment_friends.xml and then everything worked properly!

Here is the code i used:

<ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" >
    </ListView>
Armen Nalband
Armen Nalband
4,685 Points

Also having this issue

Armen Nalband
Armen Nalband
4,685 Points

Comparing my file to the files in the solution, it appears I had extra code that was auto generated.

In EditFrindsActivity, commented out the following blocks and it stopped crashing.

In onCreate: /* if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()).commit(); } */

AND at the bottom of the file: /** * A placeholder fragment containing a simple view. */

/*
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.activity_edit_friends,
                container, false);
        return rootView;
    }
}

*/