Android Open Source - HackWinds Forecast Array Adapter






From Project

Back to project page HackWinds.

License

The source code is released under:

MIT License

If you think the Android project HackWinds listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.nucc.hackwinds;
//from   www  .j a va  2 s  .  co m
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.ArrayList;

public class ForecastArrayAdapter extends ArrayAdapter<Forecast> {
    private final Context context;
    private final ArrayList<Forecast> values;

    // View holder class so views can be recycled
    static class ViewHolder {
        public TextView dayTV;
        public TextView overviewTV;
        public TextView detailTV;
    }

    public ForecastArrayAdapter(Context context, ArrayList<Forecast> values) {
        super(context, R.layout.forecast_item, values);
        this.context = context;
        this.values = values;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View rowView = convertView;
        // Make the view reusable
        if (rowView == null) {
            LayoutInflater inflater = (LayoutInflater) context
                                      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            rowView = inflater.inflate(R.layout.forecast_item, parent, false);

            // Set the view holder
            ViewHolder viewHolder = new ViewHolder();
            viewHolder.dayTV = (TextView) rowView.findViewById(R.id.forecastHeader);
            viewHolder.overviewTV = (TextView) rowView.findViewById(R.id.forecastOverview);
            viewHolder.detailTV = (TextView) rowView.findViewById(R.id.forecastDetail);

            // Set the tag so the views can be recycled
            rowView.setTag(viewHolder);
        }
        // Get the ofrecast object and the viewholder
        Forecast forecast = values.get(position);
        ViewHolder holder = (ViewHolder) rowView.getTag();

        // Set the day, brief, overview and detailed text views
        holder.dayTV.setText(forecast.day);
        holder.overviewTV.setText(forecast.overview);
        holder.detailTV.setText(forecast.detail);

        // Return the completed view to render on screen
        return rowView;
    }
}




Java Source Code List

com.nucc.hackwinds.BuoyArrayAdapter.java
com.nucc.hackwinds.BuoyFragment.java
com.nucc.hackwinds.BuoyModel.java
com.nucc.hackwinds.Buoy.java
com.nucc.hackwinds.CamFragment.java
com.nucc.hackwinds.ConditionArrayAdapter.java
com.nucc.hackwinds.ConditionModel.java
com.nucc.hackwinds.Condition.java
com.nucc.hackwinds.CurrentFragment.java
com.nucc.hackwinds.ForecastArrayAdapter.java
com.nucc.hackwinds.ForecastFragment.java
com.nucc.hackwinds.ForecastModel.java
com.nucc.hackwinds.Forecast.java
com.nucc.hackwinds.MainActivity.java
com.nucc.hackwinds.ServiceHandler.java
com.nucc.hackwinds.TideArrayAdapter.java
com.nucc.hackwinds.TideFragment.java
com.nucc.hackwinds.TideModel.java
com.nucc.hackwinds.Tide.java