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 trialRamrakesh Azhagesan
7,238 PointsBummer! Make sure you create two HashMap variables using <String, String> as the two generic types.
Hi
I am getting this error..... I keep looking at my code and i cannot figure it out why :(
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 };
String site1 = "google";
String site2 = "www.google.com";
HashMap<String,String> item = new HashMap<String,String>();
item.put(KEY_NAME,site1);
item.put(KEY_URL,site2);
}
}
1 Answer
Dan Johnson
40,533 PointsIt's looking for you to have two separate sites, both with a name and a URL expressed as a HashMap. So each site needs to be its own HashMap:
HashMap<String, String> site1 = new HashMap<String, String>();
site1.put(keys[0], "google");
site1.put(keys[1], "google.com");
HashMap<String, String> site2 = new HashMap<String, String>();
site2.put(keys[0], "bing");
site2.put(keys[1], "bing.com");