Skip to content

Instantly share code, notes, and snippets.

Created August 5, 2014 19:21
Show Gist options
  • Save anonymous/6821c625b0d1fc64eea8 to your computer and use it in GitHub Desktop.
Save anonymous/6821c625b0d1fc64eea8 to your computer and use it in GitHub Desktop.
ForecastAdapter
private static final int VIEW_TYPE_TODAY = 0;
private static final int VIEW_TYPE_FUTURE_DAY = 1;
private static final int VIEW_TYPE_COUNT = 2;
@Override
public int getItemViewType(int position) {
return position == 0 ? VIEW_TYPE_TODAY : VIEW_TYPE_FUTURE_DAY;
}
@Override
public int getViewTypeCount() {
return VIEW_TYPE_COUNT;
}
/**
* Copy/paste note: Replace existing newView() method in ForecastAdapter with this one.
*/
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
// Choose the layout type
int viewType = getItemViewType(cursor.getPosition());
int layoutId = -1;
// TODO: Determine layoutId from viewType
return LayoutInflater.from(context).inflate(layoutId, parent, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment