UPDATED CODE after Niv's answer:
Here's my Adapter method:
public class PostsListAdapter extends ArrayAdapter<String> {
/**
* ViewHolder class for layout.<br />
* <br />
*/
private static class ViewHolder {
public final RelativeLayout rootView;
public final TextView postUname;
public final TextView postText;
public final ImageView postPlatform;
public final ImageView postImage;
public final VideoView postVideo;
private ViewHolder(RelativeLayout rootView, TextView postUname, TextView postText, ImageView postPlatform, ImageView postImage, VideoView postVideo) {
this.rootView = rootView;
this.postUname = postUname;
this.postText = postText;
this.postPlatform = postPlatform;
this.postImage = postImage;
this.postVideo = postVideo;
}
public static ViewHolder create(RelativeLayout rootView) {
TextView postUname = (TextView)rootView.findViewById( R.id.post_uname );
TextView postText = (TextView)rootView.findViewById( R.id.post_text );
ImageView postPlatform = (ImageView)rootView.findViewById( R.id.post_platform );
ImageView postImage = (ImageView)rootView.findViewById( R.id.post_image );
VideoView postVideo = (VideoView)rootView.findViewById( R.id.post_video );
return new ViewHolder( rootView, postUname, postText, postPlatform, postImage, postVideo );
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder vh;
if ( convertView == null ) {
View view = mInflater.inflate( R.layout.post_list, parent, false );
vh = ViewHolder.create( (RelativeLayout)view );
view.setTag( vh );
} else {
vh = (ViewHolder)convertView.getTag();
}
Object item = getItem( position );
Log.d("Text", item.toString());
vh.postText.setText(item.toString());
return vh.rootView;
}
private LayoutInflater mInflater;
// Constructors
public PostsListAdapter(Context context, ArrayList<String> objects) {
super(context, 0, objects);
this.mInflater = LayoutInflater.from( context );
}
}
Now, the question is, how do I pass multiple arraylists, like I have eight arrays from which I have to populate the list. Like, for every item, I have to get eight items to show for that item, I have those eight arraylists sorted to keep a one-to-one correspondence.
Any idea how to handle multiple arraylists?