Created
August 5, 2014 19:21
-
-
Save anonymous/6821c625b0d1fc64eea8 to your computer and use it in GitHub Desktop.
ForecastAdapter
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
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