Last active
December 17, 2015 18:29
-
-
Save mancdevcarl/5654121 to your computer and use it in GitHub Desktop.
Custom Listview Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ListViewAdapter extends BaseAdapter { | |
private Activity activity; | |
private ArrayList<VideoObject> data; | |
private static LayoutInflater inflater = null; | |
public ImageLoader imageLoader; | |
Context cx; | |
public ListViewAdapter(Activity a, ArrayList<VideoObject> videoObjListParam) { | |
activity = a; | |
inflater = (LayoutInflater) activity | |
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | |
imageLoader = new ImageLoader(activity.getApplicationContext()); | |
data = videoObjListParam; | |
} | |
public int getCount() { | |
return data.size(); | |
} | |
public Object getItem(int position) { | |
return position; | |
} | |
public long getItemId(int position) { | |
return position; | |
} | |
public View getView(int position, View convertView, ViewGroup parent) { | |
View vi = convertView; | |
if (convertView == null) | |
vi = inflater.inflate(R.layout.list_row, null); | |
ImageView thumbImage = (ImageView) vi.findViewById(R.id.image); | |
TextView title = (TextView) vi.findViewById(R.id.title); | |
title.setText(data.get(position).getTitle()); | |
TextView author = (TextView) vi.findViewById(R.id.author); | |
author.setText(data.get(position).getAuthor()); | |
TextView year = (TextView) vi.findViewById(R.id.year); | |
year.setText(String.valueOf(data.get(position).getYear())); | |
TextView quality = (TextView) vi.findViewById(R.id.quality); | |
quality.setText(data.get(position).getQuality() + " Q"); | |
TextView duration = (TextView) vi.findViewById(R.id.duration); | |
duration.setText(data.get(position).getDuration() + " min"); | |
imageLoader.DisplayImage(data.get(position).getThumbnailUrl(), | |
thumbImage); | |
return vi; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment