I have a listview that for displaying detail data. I'm storing my data in an ArrayList of Strings. However, some of the fields may not have any data to display, but I need to keep the array length the same to match a static titles array. I can trap the empty data in my getView method in my custom base adaptor here:
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.drug_detail_cell, parent, false);
}
// check array bounds
if (position < getCount()) {
// check for null items
String item = items.get(position);
if (item != null) {
// get the text views
TextView title = (TextView) convertView.findViewById(R.id.item_title);
TextView sub = (TextView) convertView.findViewById(R.id.item_subtitle);
title.setText(titles.get(position));
sub.setText(item.toString());
} else {
// delete row
}
}
return convertView;
}
My problem is that while the data does not display, I still have an empty row in my listview. My question is how do I delete that row? Any help would be greatly appreciated. Thanks in advanced.
notifyDatasetChangedon your adapter to refresh or update listview