Sebastian Zdroana
Sebastian Zdroana

Reputation: 51

How do I get value of an ArrayList<HashMap> as a String?

I'm using Picasso to get images from a website. (TheMovieDB)

System.out.println("http://image.tmdb.org/t/p/w185" + 
        String.valueOf(posters.get(position).values())

I'm just using the code above to test a listView.setOnItemClickListener

Posters:

static ArrayList<HashMap<String, String>> posters;

The problem is when i click an item in the listview (all the items have the same link for now) it returns this:

I/System.out: http://image.tmdb.org/t/p/w185[/kqjL17yufvn9OVLyXYpvtyrFfak.jpg]

How do i get it to return the posters.get(position).values() as a string? So that it can properly concatenate the String.

I am doing that to get the movie poster links from the API and display in the listview.

if (getActivity() != null) {
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                System.out.println("http://image.tmdb.org/t/p/w185" +
                        String.valueOf(posters.get(position).values()));
            }
        });
    }

Upvotes: 1

Views: 209

Answers (1)

R.R.M
R.R.M

Reputation: 790

Try this :

System.out.println("http://image.tmdb.org/t/p/w185" + 
    String.valueOf(posters.get(position).get("yourKey"))

Upvotes: 1

Related Questions