I'm population a list view with an array and loading a new layout for each item in the array however sometimes an item may be empty/null and I don't want to inflate a layout for that object. Is there any way to do this?
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View vi = convertView;
if (vi == null)
vi = inflater.inflate(R.layout.profile_edit_layout, null);
TextView tvName = (TextView) vi.findViewById(R.id.textViewSiteName);
tvName.setText(siteNames.get(position));
TextView tvInfo = (TextView) vi.findViewById(R.id.textViewSiteInfo);
tvInfo.setText(sites.get(position));
ImageView iv = (ImageView) vi.findViewById(R.id.ivProfilePic);
iv.setImageResource(data.get(position));
return vi;
}
Say for example sites(3) is null or empty then don't inflate a layout for this item.