package com.example.android.sunshine.app;

import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * {@link ForecastAdapter} exposes a list of weather forecasts
 * from a {@link android.database.Cursor} to a {@link android.widget.ListView}.
 */
public class ForecastAdapter extends CursorAdapter {
    public ForecastAdapter(Context context, Cursor c, int flags) {
        super(context, c, flags);
    }

    /*
        Remember that these views are reused as needed.
     */
    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        return LayoutInflater.from(context).inflate(R.layout.list_item_forecast, parent, false);
    }

    /*
        This is where we fill-in the views with the contents of the cursor.
     */
    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        // our view is pretty simple here --- just a text view
        // we'll keep the UI functional with a simple (and slow!) binding.

        // Read weather icon ID from cursor
        int weatherId = cursor.getInt(ForecastFragment.COL_WEATHER_ID);
        // Use placeholder image for now
        ImageView iconView = (ImageView) view.findViewById(R.id.list_item_icon);
        iconView.setImageResource(R.drawable.ic_launcher);

        // Read date from cursor
        long date = cursor.getLong(ForecastFragment.COL_WEATHER_DATE);
        // Find TextView and set formatted date on it
        TextView dateView = (TextView) view.findViewById(R.id.list_item_date_textview);
        dateView.setText(Utility.getFriendlyDayString(context, date));

        // Read weather forecast from cursor
        String description = cursor.getString(ForecastFragment.COL_WEATHER_DESC);
        // Find TextView and set weather forecast in it
        TextView descriptionView = (TextView) view.findViewById(R.id.list_item_forecast_textview);
        descriptionView.setText(description);

        // Read user preference for metric or imperial temperature units
        boolean isMetric = Utility.isMetric(context);

        // Read high temperature from cursor
        float high = cursor.getFloat(ForecastFragment.COL_WEATHER_MAX_TEMP);
        TextView highTempView = (TextView) view.findViewById(R.id.list_item_high_textview);
        highTempView.setText(Utility.formatTemperature(high, isMetric));

        // Read low temperature from cursor
        float low = cursor.getFloat(ForecastFragment.COL_WEATHER_MIN_TEMP);

        TextView lowTempView = (TextView) view.findViewById(R.id.list_item_low_textview);
        lowTempView.setText(Utility.formatTemperature(low, isMetric));
    }
}
@@ -511,16 +511,109 @@
 apter %7B%0A
+%0A    private final int VIEW_TYPE_TODAY = 0;%0A    private final int VIEW_TYPE_FUTURE_DAY = 1;%0A%0A
     publ
@@ -708,35 +708,255 @@
 gs);%0A    %7D%0A%0A    
-/*%0A
+@Override%0A    public int getItemViewType(int position) %7B%0A        return (position == 0) ? VIEW_TYPE_TODAY : VIEW_TYPE_FUTURE_DAY;%0A    %7D%0A%0A    @Override%0A    public int getViewTypeCount() %7B%0A        return 2;%0A    %7D%0A%0A    /*%0A    
         Remember
@@ -995,16 +995,20 @@
 needed.%0A
+    
      */%0A
@@ -1109,79 +1109,282 @@
     
-return LayoutInflater.from(context).inflate(R.layout.list_item_forecast
+// Choose the layout type%0A        int viewType = getItemViewType(cursor.getPosition());%0A        int layoutId;%0A%0A        layoutId = (viewType == 0) ? R.layout.list_item_forecast_today : R.layout.list_item_forecast;%0A%0A        return LayoutInflater.from(context).inflate(layoutId
 , pa

Use 2 list_item layouts for weatherview