I\'ve been experiencing a very weird bug lately... and simply don\'t know what to do...
I have a \"Tabbed-Fragment-Activity\", which means I needed a tabhost on the bott
Use the view typing system in BaseAdapter
. Using addHeaderView()
wraps your adapter and adds unnecessary complexity that you don't need for a single View
. The getItemViewType(int)
method let's you differentiate View
types based on position within the adapter. In your getView()
method you can check to see if the position is for the header. For example:
public class YourAdapter extends BaseAdapter {
private static final int HEADER = 0;
private static final int CELL = 1;
@Override public int getItemViewType(int position) {
if (position == 0) {
return HEADER;
}
return CELL;
}
@Override public int getViewTypeCount() {
return 2;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (getItemViewType(position) == HEADER) {
// do header stuff...
return yourHeaderView;
}
// do non header stuff...
return yourNonHeaderView;
}
}