-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSongAdapter.java
More file actions
35 lines (28 loc) · 1.17 KB
/
Copy pathSongAdapter.java
File metadata and controls
35 lines (28 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.example.catie.musicplayerapp;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.ArrayList;
public class SongAdapter extends ArrayAdapter {
public SongAdapter(Context context, ArrayList<Song> pSongs) {
super(context,0, pSongs);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Check if the existing view is being reused, otherwise inflate the view
View listItemView = convertView;
if(listItemView == null) {
listItemView = LayoutInflater.from(getContext()).inflate(
R.layout.list_item, parent, false);
}
Song my_song= (Song) getItem(position);
TextView miwokTextView = (TextView) listItemView.findViewById(R.id.song_text_view);
miwokTextView.setText(my_song.getSongTitle());
TextView defaultTextView = (TextView) listItemView.findViewById(R.id.artist_text_view);
defaultTextView.setText(my_song.getArtistName());
return listItemView;
}
}