Create a beautiful Android Weather App using OpenWeatherMap API and Volley Library part 1

In this part series tutorial, we are going to learn how to create a beautiful android weather app using the OpenWeatherMap API and Volley for Network calls.

This is going to be a long tutorial but I will suggest you stick with it and at the end we will all learn something new.

If you need extended version of this android weather app with Admob, Analytic and more features, you can get the complete source code and manual for 5 $.

Before you start, head over to OpenWeatherMap.org website. For us to use their weather API in our android application, we need to create an account and obtain a unique API Key we will append in any request to OpenWeatherMap remote server.

openweathermap

For this android weather app tutorial, we are going to cover the following

1. A splash intro screen

2. Main Weather Activity Page

3. Add New Location Page – use to search for weather information about any location

4. List Location Page – that has a list of all the added locations.

 

Android Project Structure

Because we are going to create lots of different files, I have used a project structure like this to manage where each file should be. This is not perfect and feel free to choose any structure that works for you.

project structure

 

What we will be Creating – Screenshot

These are some of the screenshots for this application we will be creating.

android weather app tutorial

 

CREATE ANDROID APPLICATION

Lets start to soil our hands in code. Start up your IDE. For this tutorial, I am using the following tools and environment, feel free to use what works for you.

Windows 10

Android Studio

Sony Xperia ZL

Min SDK 14

Target SDK 23

To create a new android application project, follow the steps as stipulated below.

Go to File menu

Click on New menu

Click on Android Application

Enter Project name: AndroidWeatherApp

Package: com.inducesmile.androidweatherapp

Select Blank Activity

Name your activity : MainActivity

Keep other default selections

Continue to click on next button until Finish button is active, then click on Finish Button.

 

BUILD.GRADLE

Open the app build.gradle file, we are going to add many third party libraries. The list as shown below.

1. sdp-android:1.0.3 – for uniform dimension across different screen sizes

2. circleview:1.3 – display text inside a circle with coloured stroke

3. gson:2.6.1 – for parsing Json to plain Java object

4. volley:library:1.0.19 – for android network call

5. sqliteassethelper – sqlite database helper classes

6. joda-time – working with date and time

After add all the dependency libraries in the app build.gradle, the modify file will look like this

compile fileTree(dir: 'libs', include: ['*.jar'])
apply plugin: 'com.android.application'
android {
    compileSdkVersion 24
    buildToolsVersion "23.0.3"
    defaultConfig {
        applicationId "com.inducesmile.androidweatherapp"
        minSdkVersion 14
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.intuit.sdp:sdp-android:1.0.3'
    compile 'com.android.support:recyclerview-v7:24.0.0'
    compile 'com.github.pavlospt:circleview:1.3'
    compile 'com.google.code.gson:gson:2.6.1'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
    compile group: 'com.google.guava', name: 'guava', version: '19.0'
    compile group: 'joda-time', name: 'joda-time', version: '2.9.4'
}

 

MANIFEST.XML

For now, we are going to make some changes in the Manifest.xml file. User permissions and a custom Application class. The users permission we will use are INTERNET, ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION.

Open the Manifext.xml file and add the code below

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.inducesmile.androidweatherapp">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <application
        android:name=".helpers.CustomApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".WeatherActivity" />
        <activity
            android:name=".AddLocationActivity"
            android:parentActivityName=".WeatherActivity">
        </activity>
        <activity android:name=".ListLocationActivity">
        </activity>
    </application>
</manifest>

 

STRINGS.XML

We are going to update our project strings.xml file located in the values folder inside the res folder. Open the file and add the code below to it.

<resources>
    <string name="app_name">Android Weather App</string>
    <string name="city_country">Enugu, Nigeria</string>
    <string name="date_today">Friday, 8 July</string>
    <string name="current_temperature">26</string>
    <string name="weather_information">Partly Cloud</string>
    <string name="temp_information">26, partly cloudy</string>
    <string name="wind">WIND</string>
    <string name="wind_speed">18 km/h</string>
    <string name="humidity">HUMIDITY</string>
    <string name="humidity_rate">73%</string>
    <string name="day_of_week">Mon</string>
    <string name="location_hints">Type city or postcode</string>
    <string name="location_example">Example Malmo, Sweden</string>
    <string name="add_new_location">Add new location</string>
    <string name="stored_location">You can only store 5 locations</string>
    <string name="permission_notice">This permission is important but you can as well set your location on Location page</string>
    <string name="go_to_location">Go to location setting</string>
</resources>

 

COLORS.XML

Open the colors.xml file in the same location as the strings.xml file and add the code below to the file

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#729101</color>
    <color name="colorPrimaryDark">#4f6404</color>
    <color name="colorAccent">#FF4081</color>
    <color name="colorBlack">#000000</color>
    <color name="colorWhite">#ffffff</color>
    <string name="delete_text">X</string>
    <color name="colorBackground">#eaaf02</color>
    <color name="colorBottomBackground">#729101</color>
    <color name="colorCircleStroke">#df9502</color>
    <color name="colorSubTitle">#38455B</color>
</resources>

 

Ids.xml

Create a new value layout file in the values folder and name it ids.xml. We will store some ids in this layout file.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item type="id" name="TAG_KEY"/>
    <item type="id" name="button0"/>
    <item type="id" name="button1"/>
    <item type="id" name="button2"/>
    <item type="id" name="button3"/>
    <item type="id" name="button4"/>
</resources>

 

Extends Default Android Application Class

We will extends the default android application class so that we have some global methods we can make use of in different classes.

Create a file in the helpers package and name it CustomApplication.java. Open this file and add the below code.

import android.app.Application;
import android.content.res.AssetManager;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonReader;
import com.inducesmile.androidweatherapp.entity.ListJsonObject;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class CustomApplication extends Application {
    public InputStream getJsonStream(){
        AssetManager mgr = getAssets();
        String filename = null;
        InputStream stream = null;
        try {
            filename = "city.list.json";
            System.out.println("filename : " + filename);
            stream = mgr.open(filename, AssetManager.ACCESS_BUFFER);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return stream;
    }
    public List<ListJsonObject> readStream(InputStream stream) {
        JsonReader reader = null;
        List<ListJsonObject> messages = new ArrayList<ListJsonObject>();
        try {
            reader = new JsonReader(new InputStreamReader(stream, "UTF-8"));
            Gson gson = new GsonBuilder().create();
            reader.beginArray();
            while (reader.hasNext()) {
                ListJsonObject message = gson.fromJson(reader, ListJsonObject.class);
                messages.add(message);
            }
            reader.endArray();
            reader.close();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }catch (IOException ex) {
        }
        Collections.sort(messages, new Comparator<ListJsonObject>() {
            @Override
            public int compare(ListJsonObject listJsonObject, ListJsonObject nextListJsonObject) {
                return listJsonObject.getName().compareToIgnoreCase(nextListJsonObject.getName());
            }
        });
        return messages;
    }
}

 

CustomSharedPreference class

inside the helper folder create another class and name it CustomSharedPreference.java. This class is use to store and retrieve shared values and objects.

Open the file and add the code below in it.

import android.content.Context;
import android.content.SharedPreferences;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.inducesmile.androidweatherapp.entity.ListJsonObject;
import java.lang.reflect.Type;
import java.util.List;
public class CustomSharedPreference {
    private SharedPreferences sharedPref;
    private Gson gson;
    public CustomSharedPreference(Context context) {
        sharedPref = context.getSharedPreferences(Helper.PREFS_TAG, Context.MODE_PRIVATE);
        gson = new Gson();
    }
    public void setDataFromSharedPreferences(String key, List<ListJsonObject> listObjects) {
        String json = gson.toJson(listObjects);
        sharedPref.edit().putString(key, json).apply();
    }
    public List<ListJsonObject> getAllDataObject(String key){
        String stringObjects = sharedPref.getString(key, "");
        Type type = new TypeToken<List<ListJsonObject>>(){}.getType();
        return gson.fromJson(stringObjects, type);
    }
    public void setDataSourceIfPresent(boolean isData){
        sharedPref.edit().putBoolean(Helper.IS_DATA_PRESENT, isData).apply();
    }
    public boolean getDataSourceIfPresent(){
        return sharedPref.getBoolean(Helper.IS_DATA_PRESENT, false);
    }
    public void setLocationInPreference(String cityName){
        sharedPref.edit().putString(Helper.LOCATION_PREFS, cityName).apply();
    }
    public String getLocationInPreference(){
        return sharedPref.getString(Helper.LOCATION_PREFS, "");
    }
}

 

Helper.java

Create another class in the same folder and name it helper. It will be used to store all constant variables and global methods. Open the file and add the code below.

public class Helper {
    public static final String MANAGER_LOCATION = "Manager Location";
    public static final String LOCATION_LIST = "Location List";
    public static final String LOCATION_ERROR_MESSAGE = "Input field must be filled";
    public static final String PREFS_TAG = "prefs";
    public static final String STORED_DATA_FIRST = "data_first";
    public static final String STORED_DATA_SECOND = "data_second";
    public static final String IS_DATA_PRESENT = "isData";
    public static final String SERVER_PATH = "api.openweathermap.org/data/2.5/weather?";
    public static final String SERVER_PARAM_KEY = "q";
    public static final String LOCATION_PREFS = "location_prefs";
    public static String capitalizeFirstLetter(String original) {
        if (original == null || original.length() == 0) {
            return original;
        }
        return original.substring(0, 1).toUpperCase() + original.substring(1);
    }
}

 

Create Database Class

We will create a folder package and name it database. It will contain three classes that will help us to create and manipulate our database. The classes are

 

Database.java

import android.content.Context;
import com.readystatesoftware.sqliteasset.SQLiteAssetHelper;
public class Database extends SQLiteAssetHelper {
    private static final String DATABASE_NAMES = "sqlitedata";
    private static final int DATABASE_VERSION = 3;
    public Database(Context context) {
        super(context, DATABASE_NAMES, null, DATABASE_VERSION);
    }
}

 

DatabaseObject.java

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
public class DatabaseObject {
    private static Database dbHelper;
    private SQLiteDatabase db;
    public DatabaseObject(Context context) {
        dbHelper = new Database(context);
        this.dbHelper.getWritableDatabase();
        this.db = dbHelper.getReadableDatabase();
    }
    public SQLiteDatabase getDbConnection(){
        return this.db;
    }
    public void closeDbConnection(){
        if(this.db != null){
            this.db.close();
        }
    }
}

 

DatabaseQuery.java

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import com.inducesmile.androidweatherapp.entity.DatabaseLocationObject;
import java.util.ArrayList;
import java.util.List;
public class DatabaseQuery extends DatabaseObject{
    private final String TABLE_NAME = "data";
    private final String KEY_NAME = "_id";
    public DatabaseQuery(Context context) {
        super(context);
    }
    public List<DatabaseLocationObject> getStoredDataLocations(){
        List<DatabaseLocationObject> allLocations = new ArrayList<DatabaseLocationObject>();
        String query = "Select * from data";
        Cursor cursor = this.getDbConnection().rawQuery(query, null);
        if(cursor.moveToFirst()){
            do{
                int id = cursor.getInt(0);
                System.out.println("Response number " + id);
                String storedData = cursor.getString(cursor.getColumnIndexOrThrow("cotent"));
                System.out.println("Response number " + storedData);
                allLocations.add(new DatabaseLocationObject(id, storedData));
            }while (cursor.moveToNext());
        }
        cursor.close();
        return allLocations;
    }
    public int countAllStoredLocations(){
        int total = 0;
        String query = "Select * from data";
        Cursor cursor = this.getDbConnection().rawQuery(query, null);
        if(cursor.moveToFirst()){
            total = cursor.getCount();
        }
        cursor.close();
        return total;
    }
    public void insertNewLocation(String cityCountry){
        ContentValues values = new ContentValues();
        values.put("cotent", cityCountry);
        getDbConnection().insert(TABLE_NAME, null, values);
    }
    public boolean deleteLocation(int locationId){
        return getDbConnection().delete(TABLE_NAME, KEY_NAME + "=" + locationId, null) > 0;
    }
    public void deleteAllLocationContent(){
        getDbConnection().execSQL("delete from " + TABLE_NAME);
    }
}

 

Create Adapter Classes

We are going to use different adapter classes in this application. If you do know what the adapter class do, it is a class we will use to bind the list item views in the RecyclerView with the data source.

The following classes are either an adapter class or a Holder class.

 

CustomArrayAdapter.java

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Filter;
import android.widget.TextView;
import com.inducesmile.androidweatherapp.entity.ListJsonObject;
import com.inducesmile.androidweatherapp.R;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class CustomArrayAdapter extends ArrayAdapter<ListJsonObject> {
    private final String MY_DEBUG_TAG = "ListJsonObjectAdapter";
    private List<ListJsonObject> items;
    private List<ListJsonObject> itemsAll;
    private List<ListJsonObject> suggestions;
    private int viewResourceId;
    public CustomArrayAdapter(Context context, int viewResourceId, List<ListJsonObject> items) {
        super(context, viewResourceId, items);
        this.items = items;
        this.itemsAll = new ArrayList<>(this.items);
        this.suggestions = new ArrayList<ListJsonObject>();
        this.viewResourceId = viewResourceId;
    }
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
            LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(viewResourceId, null);
        }
        ListJsonObject listJsonObject = items.get(position);
        if (listJsonObject != null) {
            TextView listJsonObjectNameLabel = (TextView) v.findViewById(R.id.text_suggestion);
            if (listJsonObjectNameLabel != null) {
                listJsonObjectNameLabel.setText(listJsonObject.getName() + "," + listJsonObject.getCountry());
            }
        }
        return v;
    }
    @Override
    public Filter getFilter() {
        return nameFilter;
    }
    Filter nameFilter = new Filter() {
        @Override
        public String convertResultToString(Object resultValue) {
            String str = ((ListJsonObject)(resultValue)).getName();
            return str;
        }
        @Override
        protected FilterResults performFiltering(CharSequence constraint) {
            if (null != constraint) {
                if (constraint.length() == 3) {
                    for (ListJsonObject listJsonObject : itemsAll) {
                        if (listJsonObject.getName().toLowerCase().startsWith(constraint.toString().toLowerCase())) {
                            suggestions.add(listJsonObject);
                        }
                    }
                }
                if (constraint.length() >= 3) {
                    List<ListJsonObject> newData = new ArrayList<>(suggestions);
                    suggestions.clear();
                    for (ListJsonObject newList : newData) {
                        if (newList.getName().toLowerCase().startsWith(constraint.toString().toLowerCase())) {
                            suggestions.add(newList);
                        }
                    }
                }
                FilterResults filterResults = new FilterResults();
                filterResults.values = suggestions;
                filterResults.count = suggestions.size();
                System.out.println("Counting new " + suggestions.size());
                return filterResults;
            } else {
                suggestions.clear();
                return new FilterResults();
            }
        }
        @Override
        protected void publishResults(CharSequence constraint, FilterResults results) {
            List<ListJsonObject> filteredList = (List<ListJsonObject>) results.values;
            if(results != null && results.count > 0) {
                clear();
                for(Iterator<ListJsonObject> data = filteredList.iterator(); data.hasNext();){
                    ListJsonObject obtainedJsonObject = data.next();
                    add(obtainedJsonObject);
                }
                notifyDataSetChanged();
            }
        }
    };
}

 

LocationAdapter.java

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import com.inducesmile.androidweatherapp.database.DatabaseQuery;
import com.inducesmile.androidweatherapp.entity.LocationObject;
import com.inducesmile.androidweatherapp.R;
import com.inducesmile.androidweatherapp.entity.ViewEntityObject;
import com.inducesmile.androidweatherapp.helpers.CustomSharedPreference;
import java.util.ArrayList;
import java.util.List;
public class LocationAdapter extends RecyclerView.Adapter<LocationHolders> implements CompoundButton.OnCheckedChangeListener{
    private List<LocationObject> locationObjects;
    protected Context context;
    private List<ViewEntityObject> allRadioButton;
    private DatabaseQuery query;
    int[] idList = new int[]{R.id.button0, R.id.button1, R.id.button2, R.id.button3, R.id.button4};
    private CustomSharedPreference sharedPreference;
    public LocationAdapter(Context context, List<LocationObject> locationObjects) {
        this.locationObjects = locationObjects;
        this.context = context;
        allRadioButton = new ArrayList<ViewEntityObject>();
        query = new DatabaseQuery(context);
        sharedPreference = new CustomSharedPreference(context);
    }
    @Override
    public LocationHolders onCreateViewHolder(ViewGroup parent, int viewType) {
        LocationHolders viewHolder = null;
        View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.location_list, parent, false);
        viewHolder = new LocationHolders(layoutView, locationObjects);
        return viewHolder;
    }
    @Override
    public void onBindViewHolder(final LocationHolders holder, final int position) {
        holder.locationCity.setText(Html.fromHtml(locationObjects.get(position).getLocationCity()));
        holder.weatherInformation.setText(Html.fromHtml(locationObjects.get(position).getWeatherInformation()));
        holder.deleteText.setTag(R.id.TAG_KEY, String.valueOf(locationObjects.get(position).getId()));
        holder.deleteText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int databaseIndex = locationObjects.get(position).getId();
                if(!holder.selectableRadioButton.isChecked()){
                    query.deleteLocation(databaseIndex);
                    locationObjects.remove(position);
                    notifyItemRemoved(position);
                }
            }
        });
        String buttonId = sharedPreference.getLocationInPreference();
        System.out.println("Stored id " + buttonId);
        holder.selectableRadioButton.setOnCheckedChangeListener(this);
        setRadioButtonId(holder.selectableRadioButton, position);
        allRadioButton.add(new ViewEntityObject(holder.selectableRadioButton, locationObjects.get(position).getLocationCity()));
        String storedCityLocation = sharedPreference.getLocationInPreference();
        if(allRadioButton.get(position).getRadioName().equals(storedCityLocation)){
            holder.selectableRadioButton.setChecked(true);
        }
    }
    @Override
    public int getItemCount() {
        return this.locationObjects.size();
    }
    @Override
    public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
        if(isChecked){
            RadioButton radioButton = (RadioButton)compoundButton;
            int checkedRadioId = radioButton.getId();
            for(int i = 0; i < allRadioButton.size(); i++){
                if(allRadioButton.get(i).getRadioButton().getId() != checkedRadioId){
                    allRadioButton.get(i).getRadioButton().setChecked(false);
                }else{
                    String name = allRadioButton.get(i).getRadioName();
                    sharedPreference.setLocationInPreference(name);
                }
            }
        }
    }
    private void setRadioButtonId(RadioButton mButton, int position){
        if(position == 0){
            mButton.setId(idList[position]);
        }
        if(position == 1){
            mButton.setId(idList[position]);
        }
        if(position == 2){
            mButton.setId(idList[position]);
        }
        if(position == 3){
            mButton.setId(idList[position]);
        }
        if(position == 4){
            mButton.setId(idList[position]);
        }
    }
}

 

LocationHolders.java

import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.RadioButton;
import android.widget.TextView;
import com.inducesmile.androidweatherapp.R;
import com.inducesmile.androidweatherapp.entity.LocationObject;
import java.util.List;
public class LocationHolders extends RecyclerView.ViewHolder{
    private static final String TAG = LocationHolders.class.getSimpleName();
    public TextView locationCity;
    public TextView weatherInformation;
    public TextView deleteText;
    public RadioButton selectableRadioButton;
    public LocationHolders(final View itemView, final List<LocationObject> locationObject) {
        super(itemView);
        locationCity = (TextView) itemView.findViewById(R.id.city_location);
        weatherInformation = (TextView)itemView.findViewById(R.id.temp_info);
        selectableRadioButton = (RadioButton)itemView.findViewById(R.id.radio_button);
        deleteText = (TextView)itemView.findViewById(R.id.delete_row);
        deleteText.setTextColor(Color.RED);
    }
}

 

RecyclerViewAdapter.java

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.inducesmile.androidweatherapp.R;
import com.inducesmile.androidweatherapp.entity.WeatherObject;
import java.util.List;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewHolders> {
    private List<WeatherObject> dailyWeather;
    protected Context context;
    public RecyclerViewAdapter(Context context, List<WeatherObject> dailyWeather) {
        this.dailyWeather = dailyWeather;
        this.context = context;
    }
    @Override
    public RecyclerViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
        RecyclerViewHolders viewHolder = null;
        View layoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.weather_daily_list, parent, false);
        viewHolder = new RecyclerViewHolders(layoutView);
        return viewHolder;
    }
    @Override
    public void onBindViewHolder(RecyclerViewHolders holder, int position) {
            holder.dayOfWeek.setText(dailyWeather.get(position).getDayOfWeek());
            holder.weatherIcon.setImageResource(dailyWeather.get(position).getWeatherIcon());
            double mTemp = Double.parseDouble(dailyWeather.get(position).getWeatherResult());
            holder.weatherResult.setText(String.valueOf(Math.round(mTemp)) + "°");
            holder.weatherResultSmall.setText(dailyWeather.get(position).getWeatherResultSmall());
            holder.weatherResultSmall.setVisibility(View.GONE);
    }
    @Override
    public int getItemCount() {
        return 5;
    }
}

 

RecyclerViewHolders.java

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.inducesmile.androidweatherapp.R;
public class RecyclerViewHolders extends RecyclerView.ViewHolder{
    private static final String TAG = RecyclerViewHolders.class.getSimpleName();
    public TextView dayOfWeek;
    public ImageView weatherIcon;
    public TextView weatherResult;
    public TextView weatherResultSmall;
    public RecyclerViewHolders(final View itemView) {
        super(itemView);
        dayOfWeek = (TextView)itemView.findViewById(R.id.day_of_week);
        weatherIcon = (ImageView)itemView.findViewById(R.id.weather_icon);
        weatherResult = (TextView) itemView.findViewById(R.id.weather_result);
        weatherResultSmall = (TextView)itemView.findViewById(R.id.weather_result_small);
    }
}

This brings us to the end of the first part of this android weather application tutorial. In the second tutorial, we will finish up from where we stopped in this first tutorial.

Remember, that you can buy the extended version of this code with more features for 5$. Get back to me if you are interested.

OTHER INTERESTING POSTS:

3 Comments

Add a Comment