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!

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

stuck on; Adding Secondary Data with a SimpleAdapter, Objective 3-4;

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, "one");
              name.put(KEY_URL, " two");

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

  ArrayList<HashMap<String, String>> websites = new ArrayList<HashMap<String, String>> ();
  String[] keys = { KEY_NAME, KEY_URL };
  SimpleAdapter adapter = new SimpleAdapter(this,websites,android.R.layout.simple_list_item_2,keys,ids);
  websites.add(name); websites.add(url);
}

}

2 Answers

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

Sorryyy I fixed It, so ignore this post.