Android Open Source - aweather Search Cities Adapter






From Project

Back to project page aweather.

License

The source code is released under:

MIT License

If you think the Android project aweather 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 im.dema.aweather.Adapters;
/*w w w. java  2s  .  c o 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.List;

import im.dema.aweather.Models.SearchCityModel;
import im.dema.aweather.R;

/**
 * Created by dema on 15.12.14.
 */
public class SearchCitiesAdapter extends ArrayAdapter<SearchCityModel> {
    private LayoutInflater inflater;
    private static class ViewHolder {
        TextView name;
        TextView countryCode;
    }

    public SearchCitiesAdapter(Context context, int resource, List<SearchCityModel> items) {
        super(context, resource, items);
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        if(view == null) {
            viewHolder = new ViewHolder();
            view = inflater.inflate(R.layout.search_cities_item, null);
            viewHolder.name = (TextView) view.findViewById(R.id.city_name);
            viewHolder.countryCode = (TextView) view.findViewById(R.id.country_code);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        SearchCityModel model = getItem(position);
        viewHolder.name.setText(model.getName());
        viewHolder.countryCode.setText(model.getCountryCode());
        return view;
    }
}




Java Source Code List

im.dema.aweather.ApplicationTest.java
im.dema.aweather.MainActivity.java
im.dema.aweather.Adapters.CurrentWeatherListViewAdapter.java
im.dema.aweather.Adapters.SearchCitiesAdapter.java
im.dema.aweather.Fragments.CurrentWeatherListFragment.java
im.dema.aweather.Models.CurrentWeatherModelHelper.java
im.dema.aweather.Models.CurrentWeatherModel.java
im.dema.aweather.Models.SearchCityModel.java
im.dema.aweather.Popups.SearchResultWindow.java
im.dema.aweather.Services.WeatherLoaderService.java
im.dema.aweather.Utils.SwipeDismissListViewTouchListener.java