Created
December 26, 2014 00:49
-
-
Save srcreigh/4c3dab6eb802b94e2754 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final int ITEM_VIEW_TYPE_LARGE = 0; | |
public static final int ITEM_VIEW_TYPE_SMALL = 1; | |
@Override | |
public int getItemViewType(int position) { | |
if (isCategoryLarge(categories.get(position)) { | |
return ITEM_VIEW_TYPE_LARGE; | |
} else { | |
return ITEM_VIEW_TYPE_SMALL; | |
} | |
} | |
@Override | |
public int getViewTypeCount() { | |
return 2; | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
final int viewType = getItemViewType(position); | |
if (convertView == null) { | |
if (viewType == ITEM_VIEW_TYPE_LARGE) { | |
// create new large view | |
} else if (viewType == ITEM_VIEW_TYPE_SMALL) { | |
// create new small view | |
} | |
} | |
if (viewType == ITEM_VIEW_TYPE_LARGE) { | |
// set up convertView, which is guaranteed to only have been touched | |
// by code that knows it is large | |
} else if (viewType == ITEM_VIEW_TYPE_SMALL) { | |
// etc | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment