Android Open Source - MOA-Player Song Adapter






From Project

Back to project page MOA-Player.

License

The source code is released under:

MIT License

If you think the Android project MOA-Player 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 us.reimus.moaplayer;
/*  ww  w .  ja va2 s. c o  m*/
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import java.util.ArrayList;
import android.content.Context;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

public class SongAdapter extends BaseAdapter {
  private ArrayList<Song> songs;
  private LayoutInflater songInf;
  
  public SongAdapter(Context c, ArrayList<Song> theSongs){
    songs=theSongs;
    songInf=LayoutInflater.from(c);
  }
  
  @Override
  public int getCount() {
    return songs.size();
  }
   
  @Override
  public Object getItem(int arg0) {
      // TODO Auto-generated method stub
      return null;
  }
   
  @Override
  public long getItemId(int arg0) {
      // TODO Auto-generated method stub
      return 0;
  }
   
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      // Map to song layout.
    LinearLayout songLay = (LinearLayout)songInf.inflate(R.layout.song, parent, false);
    // Get title and artist views.
    TextView songView = (TextView)songLay.findViewById(R.id.song_title);
    TextView artistView = (TextView)songLay.findViewById(R.id.song_artist);
    // Get song using position.
    Song currSong = songs.get(position);
    // Get title and artist strings.
    songView.setText(currSong.getTitle());
    artistView.setText(currSong.getArtist());
    // Set position as tag.
    songLay.setTag(position);
      return songLay;
  }
}




Java Source Code List

us.reimus.moaplayer.DirectoryAdapter.java
us.reimus.moaplayer.MainActivity.java
us.reimus.moaplayer.MusicController.java
us.reimus.moaplayer.MusicService.java
us.reimus.moaplayer.SongAdapter.java
us.reimus.moaplayer.Song.java