Android How To Program 3rd Edition Deitel Solutions Manual 1
Android How To Program 3rd Edition Deitel Solutions Manual 1
0134444302 9780134444307
Download solution manual at:
https://testbankpack.com/p/solution-manual-for-android-how-to-
program-3rd-edition-deitel-0134444302-9780134444307/
7 WeatherViewer App
Objectives
In this chapter you’ll:
■ Use the free
OpenWeatherMap.org
REST web services to get a
16-day weather forecast for a
city specified by the user.
■ Use an AsyncTask and an
HttpUrlConnection to
invoke a REST web service or
to download an image in a
separate thread and deliver
results to the GUI thread.
■ Process a JSON response
using package org.json
classes JSONObjects and
JSONArrays.
■ Define an ArrayAdapter
that specifies the data to
display in a ListView.
■ Use the ViewHolder
pattern to reuse views that
scroll off the screen in a
ListView, rather than
creating new views.
■ Use the material design
components
TextInputLayout,
Snackbar and
FloatingActionButton
from the Android Design
Support Library.
2 Chapter 7 WeatherViewer 7.2
App Test-Driving the WeatherViewer App 2
7.1 Introduction
The WeatherViewer app (Fig. 7.1) uses the free OpenWeatherMap.org REST web services
to obtain a specified city’s 16-day weather forecast. The app receives the weather data in
JSON (JavaScript Object Notation) data format. The list of weather data is displayed in a
ListView—a view that displays a scrollable list of items. In this app, you’ll use a custom
list-item format to display:
• a weather-condition icon
• the day of the week with a text description of that day’s weather
• the day’s low and high temperatures (in °F), and
• the humidity percentage.
The preceding items represent a subset of the returned forecast data. For details of the data
returned by the 16-day weather forecast API, visit:
http://openweathermap.org/forecast16
Fig. 7.1 | Weather Viewer app displaying the New York, NY, US weather forecast.
entered the city, touch the circular FloatingActionButton containing the done icon
( ) to submit the city to the app, which then requests that city’s 16-day weather forecast
(shown in Fig. 7.1).
APPENDIX
THE MAD DUKE OF NAXOS