//Displaying Youtube videos in a listview : i'm making an android application to get started with youtube api im doing the search of an edit text then when action done its should display the videos in my list view .. the problem i have that it only displays 5 videos in the list view and i want that to be dynamic so when i scroll down it displays 5 another videos and so on how can i do this ?
private void updateVideosFound() {
ArrayAdapter<VideoItem> adapter = new ArrayAdapter<VideoItem>(getApplicationContext(), R.layout.video_item, searchResults) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = getLayoutInflater().inflate(R.layout.video_item, parent, false);
}
ImageView thumbnail = (ImageView) convertView.findViewById(R.id.video_thumbnail);
TextView title = (TextView) convertView.findViewById(R.id.video_title);
TextView description = (TextView) convertView.findViewById(R.id.video_description);
VideoItem searchResult = searchResults.get(position);
Picasso.with(getApplicationContext()).load(searchResult.getThumbnailURL()).into(thumbnail);
title.setText(searchResult.getTitle());
description.setText(searchResult.getDescription());
return convertView;
}
};
videosFound.setAdapter(adapter);
videosFound.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
});
}