Android Open Source - hts-cycle Play List Activity

From Project

Back to project page hts-cycle.


The source code is released under:

GNU General Public License

If you think the Android project hts-cycle listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package it.uniroma2.musicsharep2p;
//from  w  ww  .  j  a  v  a2  s  . c o  m
import java.util.ArrayList;
import java.util.HashMap;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class PlayListActivity extends ListActivity {
  // Songs list
  public ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();

  public void onCreate(Bundle savedInstanceState) {

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

    SongsManager plm = new SongsManager();
    // get all songs from sdcard
    this.songsList = plm.getPlayList();

    // looping through playlist
    for (int i = 0; i < songsList.size(); i++) {
      // creating new HashMap
      HashMap<String, String> song = songsList.get(i);

      // adding HashList to ArrayList

    // Adding menuItems to ListView
    ListAdapter adapter = new SimpleAdapter(this, songsListData,
        R.layout.playlist_item, new String[] { "songTitle" }, new int[] { });


    // selecting single ListView item
    ListView lv = getListView();
    // listening to single listitem click
    lv.setOnItemClickListener(new OnItemClickListener() {

      public void onItemClick(AdapterView<?> parent, View view,
          int position, long id) {
        // getting listitem index
        int songIndex = position;

        // Starting new intent
        Intent in = new Intent(getApplicationContext(),
        // Sending songIndex to PlayerActivity
        in.putExtra("songIndex", songIndex);
        setResult(100, in);
        // Closing PlayListView

Java Source Code List