title: How to store and then pass an arrayList of all checked Items (HashMap objects items) from a ListView in Android?
body: <p>Hey everyone I am new to Android programming and need some Help. I have a list view that consists of HashMap objects. These hashMap objects can be selected by checking a check box. (So basically I have a check box list). What I am trying to do is Store all the HashMap objects (or items) that are checked in the ListView in an ArrayList. I then want to Pass this arrayList to another activity when a button is pressed. I've seen some examples of people storing string data but I need some help on how I would store "checked" HashMap objects in a listView into an ArrayList. So at the end all I want is an ArrayList that consists of objects (items) that were checked in the list which I can then pass.</p>
  
  <p>What program goal is: allow user to select songs based on category and create their own custom playlist. The user will be presented songs for one category, they will select the songs they want from that category and then push a "Next" button which will send them to a new activity where they will be presented a new category of songs. At each category I am trying to store their selection and pass it along from activity(category) to activity(category). But the passing is not working. I could be doing something way off. Need some advice what or how to do. -Thanx</p>
  
  <p>some code: Not the most organized I know. New to android so any pointers or things I should change</p>
  
  <pre><code>   @Override
     public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.playlist);
  
      //final ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsListData = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
      SongsManager plm = new SongsManager();
      // get all songs from sdcard
      this.songsList = plm.getPlayList();
      TextView label = new TextView(this);
      label.setText("Warm-up");
      label.setTextSize(16);
      label.setBackgroundColor(Color.WHITE);
      label.setTextColor(Color.BLACK);
  
      final ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsListData = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      // looping through playlist
      for(HashMap hs: songsList){
       if(hs.containsValue("Warm-up/cool down"))
      songsListData.add(hs);
       }
  
      // NEXT button
      Button btnLoadMore = new Button(this);
      btnLoadMore.setText("Next");
      ListView lv = getListView();
      lv.addHeaderView(label);
  
  // Adding Load More button to lisview at bottom
        lv.addFooterView(btnLoadMore);
  
      //List&lt;Model&gt; selectedlist = getModel(songsListData);
      ArrayAdapter&lt;Model&gt; adapter = new InteractiveArrayAdapter(this,
          getModel(songsListData));
  
      setListAdapter(adapter);
  
      //Listening to Load More button click event
  
      btnLoadMore.setOnClickListener(new View.OnClickListener() {
      @Override
  public void onClick(View arg0) {
        String priorSongs = "priorSongs";
        List&lt;Model&gt; selSongs = getModel(songsListData);
        Intent i = new Intent(WarmUp.this, SlowWalking.class);
        i.putExtra(priorSongs, selSongs);
        startActivity(i); 
  }
  });
  
      lv.setOnItemClickListener(new OnItemClickListener() {
  
      @Override
      public void onItemClick(AdapterView&lt;?&gt; parent, View view,
        int position, long id) {
  
       // getting listitem index
      int songIndex = position;
  
      // Starting new intent
      Intent in = new Intent(getApplicationContext(),
                          AndroidBuildingMusicPlayerActivity.class);
      in.putExtra("songIndex", songIndex);
      startActivity(in);
      finish();
              }
          });
  
      }
      private List&lt;Model&gt; getModel(ArrayList&lt;HashMap&lt;String, String&gt;&gt; songsListData) {
          List&lt;Model&gt; list = new ArrayList&lt;Model&gt;();
          for (HashMap&lt;String, String&gt; map : songsListData)
              for (Entry&lt;String, String&gt; entry : map.entrySet())
                   if (entry.getKey() == "songTitle")
                       list.add(get(entry.getValue()));
  
          // Initially select one of the items
          //list.get(1).setSelected(true);
          return list;
        }
  </code></pre>