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 trialRicky Sparks
22,249 PointsCant add SimpleAdapter?
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 };
SimpleAdapter adapter = new SimpleAdapter(this,website,android.R.layout.simple_list_item_2,keys,ids);
// Add code here!
HashMap<String, String> website1 = new HashMap<String, String>();
HashMap<String, String> website2 = new HashMap<String, String>();
website1.put(KEY_NAME, "Treehouse");
website1.put(KEY_URL, "http://teamtreehouse.com");
website2.put(KEY_NAME, "Tyranski");
website2.put(KEY_URL, "http://tyranski.com");
ArrayList<HashMap<String, String>> websites = new ArrayList<HashMap<String, String>> ();
websites.add(website1);
websites.add(website2);
}
}
Ricky Sparks
22,249 Points./WebsiteListActivity.java:16: cannot find symbol symbol : variable String location: class WebsiteListActivity SimpleAdapter adapter = new SimpleAdapter(this,String, android.R.layout.simple_list_item_2,keys,ids); ^ 1 error
1 Answer
Delia E. Larez
3,851 PointsHave you tried setting the adapter after the HashMap?
Timothy Boland
18,237 PointsTimothy Boland
18,237 PointsWhat error are you getting?