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

Adapting Data for Display in a List Stage 4 CodeChallenge

Inside the onCreate() method, create two HashMap<String, String> variables and in each one, store a website name value using KEY_NAME as the key and the website URL value using KEY_URL as the key.

i don't understand what i'm doing wrong, help would be appriciated.

here's the code:

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> map = new HashMap>String, String>();
      map.put(KEY_NAME, "treehouse");
      map.put(KEY_URL, "http://teamtreehouse.com/home");
        // Add code here!
    }
}

Thanks for your time. Ziga :D

1 Answer

Create a second HashMap variable just like the one that you already have, and add another website to it. Also, make sure that all of the code that you write is below the // Add code here comment. I think that the quiz validation checks that your code is below that.