I have create a sample which has differet layout for few rows in ListView based on the this link. Here is the layout

As i want only first row to have a different layout , whenever the position is zero i am applying layout one ( Name & Phone) and for rest i am applying layout two (Address).
the problem i am facing is when i fire notifyDataSetChanged on adapter , only my Address get changed but Name & Phone row i.e. first row doesn’t update. I am firing notifyDataSetChanged when the submenu item is selected.
Here is the code.
public static final int TYPE_ADDRESS = 1;
public static final int TYPE_NAME = 0;
public static final int TYPE_MAX_COUNT =2;
@Override
public int getItemViewType(int position) {
if(position == 0)
return TYPE_NAME;
else
return TYPE_ADDRESS;
}
@Override
public int getViewTypeCount() {
return TYPE_MAX_COUNT;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder=null;
int type = getItemViewType(position);
System.out.println("getView " + position + " " + convertView + " type = " + type);
if (convertView == null) {
holder = new ViewHolder();
switch (type) {
case TYPE_ADDRESS:
convertView = mInflater.inflate(R.layout.layout_address, null);
holder.address = (TextView) convertView.findViewById(R.id.address_id);
holder.address.setText(data.getAddress(position));
break;
case TYPE_NAME:
convertView = mInflater.inflate(R.layout.layout_name, null);
holder.name = (TextView)convertView.findViewById(R.id.name_id);
holder.phone = (TextView)convertView.findViewById(R.id.phone_id);
holder.name.setText(data.getName(position));
holder.phone.setText(data.getPhone(position));
break;
}
convertView.setTag(holder);
}else {
holder = (ViewHolder) convertView.getTag();
}
return convertView;
}
static class ViewHolder {
TextView address;
TextView name;
TextView phone;
}
AFAIK, you need to manage views (like setting text) outside
if (convertView == null){}else{}block, since you need it to be invoked in any case, not only on view creating. Could it be the issue?