Android Open Source - g3m_owm Data Source Adapter






From Project

Back to project page g3m_owm.

License

The source code is released under:

Copyright (c) 2013, Glob3 Mobile, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are m...

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

/**
 * /*  www  . ja  v a2 s.c  o m*/
 */


package com.glob3.mobile.owm;

import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Color;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;


/**
 * @author mdelacalle
 * 
 */

@SuppressLint("DefaultLocale")
public class DataSourceAdapter
         extends
            ArrayAdapter {

   private final Activity          _context;
   private final ArrayList<String> _itemList;


   /**
    * @param context
    * @param textViewResourceId
    */
   public DataSourceAdapter(final Activity context,
                            final ArrayList<String> dataSourceList) {
      super(context, R.layout.adapterrow);
      this._context = context;
      this._itemList = dataSourceList;
   }


   @Override
   public View getView(final int position,
                       final View convertView,
                       final ViewGroup parent) {

      final LayoutInflater inflater = _context.getLayoutInflater();
      final View row = inflater.inflate(R.layout.adapterrow, null);
      final TextView var = (TextView) row.findViewById(R.id.layername);
      var.setText(_itemList.get(position));
      var.setGravity(Gravity.CENTER_VERTICAL);
      var.setTextSize(15);
      var.setTextColor(Color.BLACK);


      var.setBackgroundColor(_context.getResources().getColor(R.color.transparent_background));
      return row;
   }


   @Override
   public int getCount() {
      return _itemList.size();
   }


   @Override
   public View getDropDownView(final int position,
                               final View convertView,
                               final ViewGroup parent) {

      final LayoutInflater inflater = _context.getLayoutInflater();
      final View row = inflater.inflate(R.layout.adapterrow, null);
      final TextView var = (TextView) row.findViewById(R.id.layername);
      var.setText(_itemList.get(position));
      var.setGravity(Gravity.CENTER_VERTICAL);
      var.setTextSize(15);
      var.setTextColor(Color.BLACK);
      var.setBackgroundColor(_context.getResources().getColor(R.color.transparent_background));
      return row;
   }


   @Override
   public String getItem(final int position) {
      return _itemList.get(position);
   }
}




Java Source Code List

com.glob3.mobile.owm.DataSourceAdapter.java
com.glob3.mobile.owm.Dialogs.java
com.glob3.mobile.owm.G3MOWMMainActivity.java
com.glob3.mobile.owm.GPSTracker.java
com.glob3.mobile.owm.Prefs.java
com.glob3.mobile.owm.SettingsActivity.java
com.glob3.mobile.owm.shared.G3MOWMBuilder.java
com.glob3.mobile.owm.shared.G3MOWMListener.java
com.glob3.mobile.owm.shared.data.DataRetriever.java
com.glob3.mobile.owm.shared.data.DialogDataListener.java
com.glob3.mobile.owm.shared.data.Place.java
com.glob3.mobile.owm.shared.data.Places.java
com.glob3.mobile.owm.shared.data.SimpleRasterLayerBuilder.java
com.glob3.mobile.owm.shared.data.Utils.java
com.glob3.mobile.owm.shared.data.WeatherForecastParser.java
com.glob3.mobile.owm.shared.data.WeatherForecast.java
com.glob3.mobile.owm.shared.data.Weather.java