Back to project page SimpleMusicPlayer.
The source code is released under:
Copyright 2011 Micha? Kazior. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...
If you think the Android project SimpleMusicPlayer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.michalkazior.simplemusicplayer; /* w ww. j av a 2 s . c o m*/ import java.io.File; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; public class SongAdapter extends android.widget.BaseAdapter { private Song[] songs; private LayoutInflater li; public SongAdapter(Context context, Song[] songs) { super(); this.songs = songs; this.li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public void setItems(Song[] songs) { this.songs = songs; notifyDataSetChanged(); } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { v = li.inflate(R.layout.listitem, null); } if (position >= 0 && position < songs.length) { Song s = songs[position]; File f = new File(s.getPath()); TextView tv1 = (TextView) v.findViewById(R.id.listItemTextView1); TextView tv2 = (TextView) v.findViewById(R.id.listItemTextView2); tv1.setText(f.getName()); tv2.setText(f.getParent()); } return v; } @Override public int getCount() { return songs.length; } @Override public Object getItem(int position) { return songs[position]; } @Override public long getItemId(int position) { return songs[position].getId(); } }