0

I have a really simple problem I think but just cant figure it out.

I want to be able to take someting out of a Hashmap but just cant get it to work.

Here is the code:

try{

        JSONArray  deelnemers = json.getJSONArray("deelnemers");

        int Key = getIntent().getIntExtra("Key", -1);


            { HashMap<String, String> map = new HashMap<String, String>();  
            JSONObject e = deelnemers.getJSONObject(Key);

            map.put("id",  String.valueOf(Key));
            map.put("name", "Naam: " +  e.getString("naamingw2"));
            map.put("sex", "Geslacht: " +  e.getString("geslacht"));
            map.put("rank", "Rang: " +  e.getString("rang"));
            map.put("picture", "http://www.de-saksen.nl/2/images/comprofiler/" + e.getString("avatar"));
            mylist.add(map);            
        }   
            String URL = new String (mylist.get("picture"));
            WebView WV = (WebView) findViewById(R.id.webView1);              
            WV.loadUrl(URL);

I get an compiller error at (mylist.get("picture"));

2
  • 2
    "picture" is in map, not in mylist, I suppose. Commented Jul 31, 2012 at 9:12
  • shouldn't it be map.get("picture") Or ((HashMap)mylist.get(0)).get("picture") Commented Jul 31, 2012 at 9:13

1 Answer 1

1

I could be missing something but the name of your HashMap is "map", not "mylist".

Edit: If mylist represents a list containing your HashMap, then you can do the following:

mylist.get(0).get("picture");
Sign up to request clarification or add additional context in comments.

1 Comment

String URL = mylist.get(0).get("picture"); works like a charm

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.