I have a custom listview and want to return / inflate depending on condition. i want rows displayed or not displayed depending on a condition.
In getView() i have the following
if (convertView == null) {
// Inflate the layout
LayoutInflater li = getLayoutInflater();
convertView = li.inflate(
R.layout.contactos_list_item, null);
contactViewHolder = new ContactViewHolder();
contactViewHolder.imgContact = (ImageView) convertView
.findViewById(R.id.flag);
contactViewHolder.txtViewContactName = (TextView) convertView
.findViewById(R.id.txtView_name);
contactViewHolder.txtViewPhoneNumber = (TextView) convertView
.findViewById(R.id.txtview_number);
convertView.setTag(contactViewHolder);
} else {
contactViewHolder = (ContactViewHolder) convertView.getTag();
}
and i want to return
if(condition)
{
return convertView;
}
else
{
LayoutInflater li = getLayoutInflater();
convertView=li.inflate(R.layout.row_null,null);
return convertView;
}
i have the appropriate xml layout but the application stops working. what should i change so the