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

Adding Secondary Data with a SimpleAdapter Code Challenge part 1

import android.os.Bundle;
import android.widget.SimpleAdapter;

public class WebsiteListActivity extends ListActivity {

    public static final String KEY_NAME = "name";
    public static final String KEY_URL = "url";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_website_list);

        String[] keys = { KEY_NAME, KEY_URL };
        int[] ids = { android.R.id.text1, android.R.id.text2 };

        HashMap<String, String> name = new HashMap<String, String>();
        name.put(KEY_NAME, value);
          name.put(KEY_URL, value);

        HashMap<String, String> url = new HashMap<String, String>();
        url.put(KEY_NAME, value);
        url.put(KEY_URL, value);

    }
}

hi

this is what i have done in the first part of the code challenge, i cant really see what i am doing wrong, can anyone point me in the right direction

thank

chris

2 Answers

Try adding some String values to where you have written value.

Something like this will pass the code challenge:

HashMap<String, String> name = new HashMap<String, String>();
name.put(KEY_NAME, "One");
name.put(KEY_URL, "Two");

HashMap<String, String> url = new HashMap<String, String>();
url.put(KEY_NAME, "Three");
url.put(KEY_URL, "Four");
Steven Williams
Steven Williams
7,333 Points

Changing the "value" to KEY_URL as the second parameter of the put methods will pass the challenge as well.

HashMap<String, String> name = new HashMap<String, String>();
        name.put(KEY_NAME, KEY_URL);
        name.put(KEY_URL, KEY_URL);

        HashMap<String, String> url = new HashMap<String, String>();
        url.put(KEY_NAME, KEY_URL);
        url.put(KEY_URL, KEY_URL);