Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8084681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:52:08+00:00 2026-06-05T17:52:08+00:00

I have an ArrayList of HashMap like this: ArrayList<HashMap<String, String>> playListSongs = new ArrayList<HashMap<String,

  • 0

I have an ArrayList of HashMap like this:

ArrayList<HashMap<String, String>> playListSongs = new ArrayList<HashMap<String, String>>();

I populate the list like this:

for (int i1 = 0; i1 < nl.getLength(); i1++) {
  // creating new HashMap
  HashMap<String, String> map = new HashMap<String, String>();
  Element e = (Element) nl.item(i1);
  // adding each child node to HashMap key => value
  map.put(KEY_SONGS, String.valueOf(i1));
  map.put(KEY_FILE, parser.getValue(e, KEY_FILE));
  map.put(KEY_DURATION, parser.getValue(e, KEY_DURATION));
  map.put(KEY_FILE, parser.getValue(e, KEY_FILE));
  map.put(KEY_ALBUM, parser.getValue(e, KEY_ALBUM));
  map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));
  map.put(KEY_ARTIST, parser.getValue(e, KEY_ARTIST));
  map.put(KEY_ARTWORK, parser.getValue(e, KEY_ARTWORK));
  // Songs List of selected playlist
  playListSongs.add(map);
  // list view bind
  PopulateList(playListSongs);
}

Now i want to Get Album and songs of a specific Artist and song count from HashMap-array-list(playListSongs) to bind it to the list view.

How can I achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:52:10+00:00Added an answer on June 5, 2026 at 5:52 pm

    You can use this method to get songs of specific artist:

    private ArrayList<String> getSongsByArtist(String artist){
        ArrayList<String> songs = new ArrayList<String>();
        for (HashMap<String, String> hashMap : playListSongs) {
            if(hashMap.get(KEY_ARTIST).equals(artist)){
                songs.add(hashMap.get(KEY_TITLE));
            }
        }
        return songs;       
    }
    

    To get distinct artists use following method:

    private ArrayList<String> getDistinctArtists(){
        HashMap<String,String> duplicateTracker = new HashMap<String, String>();
        ArrayList<String> distinctArtists = new ArrayList<String>();
        for (HashMap<String, String> hashMap : playListSongs) {
            // Check whether artist is already added or not
            if(duplicateTracker.containsKey(hashMap.get(KEY_ARTIST))==false){
                //Add artist name to hash map
                duplicateTracker.put(hashMap.get(KEY_ARTIST), hashMap.get(KEY_ARTIST));
                distinctArtists.add(hashMap.get(KEY_ARTIST));
            }
        }
        return distinctArtists;     
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code like this Map<String, List> searchMap = new HashMap<String, List>(); for(int
I have set up a HashMap like so: Map<String, ArrayList<String>> theAccused = new HashMap<String,
i have a Map<ArrayList<String>, ArrayList<String> myMap = new HashMap<ArrayList<String>,ArrayList<String>>(); List<String> list1 = new ArrayList<String>();
I have a map: Map<String, String> ht = new HashMap(); and I would like
I have an ArrayList<HashMap<String, String>> . I'd like to quickly extract from this a
I have a hashmap like this public HashMap <String,People> valueHashMap = new Hashmap(); Here
I have a java Hash, the structure is like this: HashMap<Integer, ArrayList<String>> finalMap =
I have a listview populated like this: lv1 = (ListView) findViewById(R.id.ListView01); ArrayList<HashMap<String, String>> mylist
I have a List of HashMap such as below ArrayList l = new ArrayList
I have a HashMap<String,String> and there is a static method which returns this map

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.