Android Open Source - UWWeather List Array Adapter






From Project

Back to project page UWWeather.

License

The source code is released under:

This software is hereby placed in the public domain. gdmalet Tue Mar 15 10:51:10 EDT 2011

If you think the Android project UWWeather 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

/**
 * An adapter that is used when drawing the main window list of details.
 *///from w  w w  .  j  a va  2 s  .c  o  m
package ca.uwaterloo.android.UWWeather;

import java.util.ArrayList;

import android.app.Activity;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

/**
 * @author gdmalet
 *
 */
public class ListArrayAdapter extends ArrayAdapter<Pair<String,String>> {
  private final Activity context;
  private final ArrayList<Pair<String,String>> details;

  public ListArrayAdapter(Activity context, ArrayList<Pair<String,String>> details) {
    super(context, R.layout.rowlayout, details);
    this.context = context;
    this.details = details;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = context.getLayoutInflater();
    View rowView = inflater.inflate(R.layout.rowlayout, null, true);

    String str;
    
    TextView label = (TextView) rowView.findViewById(R.id.label);
    str = details.get(position).first;
    label.setText(str);

    TextView value = (TextView) rowView.findViewById(R.id.value);
    str = details.get(position).second;
    value.setText(str);
    
    return rowView;
  }
}




Java Source Code List

ca.uwaterloo.android.UWWeather.ListArrayAdapter.java
ca.uwaterloo.android.UWWeather.UWWeatherActivity.java
ca.uwaterloo.android.UWWeather.UWWeatherWidget.java
ca.uwaterloo.android.UWWeather.WebFetch.java
ca.uwaterloo.android.UWWeather.parseWeatherXML.java