Presentation Title© free-ppt-templates.com
New Activities and Intents
Rich and responsive Layouts
How we will building Sunshine?
Introducing Sunshine
Have ability to share the weather with freands
Push notification about weather condition
© free-ppt-templates.com
Simple consept
So, How we will building it?
Prepare your Android Studio, make sure you already install it
properly
Why we should using Android Studio?, Why not eclipse?
© free-ppt-templates.com
The Final version (1.1) of android studio was released
There are many features that needed by developer to help develop
their app
And many more
Need a help for installing Android Studio?
If you need a help for installing android studio you can see it in
this page
What we choose?
Choose API Level 10 (2.3.3) Gingerbread if you want to support most
android device.
Why not API Level 8 (2.2) Froyo?
Lower API levels target more devices, but have fewer features
available.
© free-ppt-templates.com
© free-ppt-templates.com
© free-ppt-templates.com
Right click on "app" directory then choose -> new -> image
asset
You can choose your own icon or you can use icon we provide in this
page http://asc.harisuddin.com/finish-creating-a-new-project
© free-ppt-templates.com
You can use emulator like Android Virtual Device (AVD), genymotion
(recommended), bluestack, etc.
You also can use your phisical devices to run your project
© free-ppt-templates.com
© free-ppt-templates.com
© free-ppt-templates.com
Github
Before we continue to our project, i ask you to create account in
github
You have 20 minutes to create it, when you finish submit your
account name to bit.ly/ascGithubSubmission
© free-ppt-templates.com
bit.ly/KuisionerASC1
© free-ppt-templates.com
In this courses we will using sunshine github repository at
https://github.com/udacity/Sunshine-Version-2
© free-ppt-templates.com
After courses finish (every week) you asked to push your project to
github, so we can monitor your project activity.
How to push it?
Don't worry, Android Studio has a feature to easily share your
project to github.
© free-ppt-templates.com
Create UI
ListView is a view that contains one or more view that used to
display sets of data. In this case, ListView is used to display
weather information.
© free-ppt-templates.com
Case : Create new List Item
As we may know from previous slide that ListView contains one or
more view. So, now we need to make view that represent individual
item that will be viewed in ListView. Later, we will name it as
ListItem.
Now, make new layout called list_item_forecast, define a TextView
as the root view, and give ID list_item_forecast_textview to the
TextView. If you have problem regarding the instruction above, feel
free to asks the facilitator.
© free-ppt-templates.com
© free-ppt-templates.com
Case : Modify fragment_main
We need to modify fragment_main that represent our previous ‘Hello
World’ to become layout that contains ListView with ID
listview_forecast.
Because we only have one view, we also change our layout to
FrameLayout.
© free-ppt-templates.com
© free-ppt-templates.com
ListView
After completing case above, we have fragment that contains
ListView, ready to populated with data. ListView will use ListItem
layout (the one we created before) to display the data to the
screen.
© free-ppt-templates.com
In MainActivity.java, navigate to PlaceholderFragment class, and
create ArrayList of data on onCreateView method.
© free-ppt-templates.com
© free-ppt-templates.com
Adapter
© free-ppt-templates.com
Case : Initialize the Adapter
After knowing the usage of Adapter, we will initialize an Adapter
for our fake data to be populated to the ListView.
Create ArrayAdapter<String> in PlaceholderFragment class
onCreateView() with parameters:
Context
© free-ppt-templates.com
Context : Interface to global information about an application
environment. This is an abstract class whose implementation is
provided by the Android system. It allows access to
application-specific resources and classes, as well as up-calls for
application-level operations such as launching activities,
broadcasting and receiving intents, etc.
© free-ppt-templates.com
Referencing View to Code
You may notice that we haven’t connect our layout to the code. To
connect layout to the code, simply use
<ViewClass> <varName> = (<ViewClass>)
this.findViewById(R.id.<ID of the view>);
© free-ppt-templates.com
Case : Bind Adapter to the ListView
After we know how to reference a view to the code, we will try to
reference the ListView on the layout to the PlaceholderFragment
class onCreateView()
After that, call method setAdapter from ListView and give parameter
the data.
© free-ppt-templates.com
© free-ppt-templates.com
Thanks for attending our first lesson.
In the next lessons we will learn how to connect our sunshine to
the cloud, so i hope you prepare your self with learning about HTTP
Request, AsyncTask, Permission, and JSON(Javascript Object
Notation)
for evaluation to our first lesson please submit your suggestion
here: