0
The Greenoid’s GuideTo Building  Android™ Apps [Part–2/6]<br />Android & the Green Robot <br />are a trademark of Google I...
The App Innards<br />http://greenoid.blogspot.com (Oct 2010)<br />
What Goes into an App?<br />Activities<br />Each activity is an Android version of a basic UI block<br />Content Provider<...
Inside An Android Project<br />The Manifest File<br />A declaration of all components inside your application, like activi...
Writing an App<br />Thankfully <br />when you click on New Project in Eclipse the basic skeleton and Manifest file are aut...
The Skeleton Explained<br />MyActivity  extends  Activity <br />Think of the Activity like a high level UI container<br />...
The Widget Palette<br />All Widgets extend View<br />TextView - A basic label widget<br />Button - Well, it’s a button<br ...
Sample Code For the Lazy<br />package com.droid.clockwork;<br />import android.app.Activity;<br />import android.os.Bundle...
Coming soon Part 3/6<br />http://greenoid.blogspot.com (Oct 2010)<br />Meanwhile checkout our blog: http://greenoid.blogsp...
Upcoming SlideShare
Loading in...5
×

Learning Android Part 2/6

1,070

Published on

The Greenoid's Guide to learning Android is a 6 part series on building applications on the Android Platform

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,070
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Learning Android Part 2/6"

  1. 1. The Greenoid’s GuideTo Building Android™ Apps [Part–2/6]<br />Android & the Green Robot <br />are a trademark of Google Inc.<br />http://greenoid.blogspot.com (Oct 2010)<br />
  2. 2. The App Innards<br />http://greenoid.blogspot.com (Oct 2010)<br />
  3. 3. What Goes into an App?<br />Activities<br />Each activity is an Android version of a basic UI block<br />Content Provider<br />You write content providers to share data of any form residing on the device with other applications<br />Services<br />If you want your code to run always, without any UI elements, services are the answer<br />Intents<br />A notification mechanism for system events like hardware changes, incoming sms … you can also create your own intents to notify others.<br />http://greenoid.blogspot.com (Oct 2010)<br />
  4. 4. Inside An Android Project<br />The Manifest File<br />A declaration of all components inside your application, like activities, services, user permissions, SDK version, and optional libraries in use.<br />XML Layouts<br />You can specify an UI layout in XML and attach it to an activity, giving you freedom to modify the UI without worrying about code.<br />R.java<br />An auto-generated file that connects resources like the XML layout definitions to java code.<br />http://greenoid.blogspot.com (Oct 2010)<br />
  5. 5. Writing an App<br />Thankfully <br />when you click on New Project in Eclipse the basic skeleton and Manifest file are auto-magically created.<br />The skeleton<br />public class MyActivityextends Activity {<br />@Override<br /> public void onCreate(Bundle icicle) {<br />super.onCreate(icicle);<br />TextViewtv = new TextView(this);<br />setContentView(tv);<br />}<br />}<br />http://greenoid.blogspot.com (Oct 2010)<br />
  6. 6. The Skeleton Explained<br />MyActivity extends Activity <br />Think of the Activity like a high level UI container<br />Public void onCreate(Bundle icicle) <br />Invoked when the activity is created, you might want to create some basic UI widget like a button or TextView here<br />setContentView( TextView )<br />Since the Activity is a high-level UI container, you will have to call setContentView(button/label) to add your widget to the container<br />If you created a button<br />You will have to do btn.setOnClickListener() to receive events<br />And implement public void onClick(View v) to handle it<br />http://greenoid.blogspot.com (Oct 2010)<br />
  7. 7. The Widget Palette<br />All Widgets extend View<br />TextView - A basic label widget<br />Button - Well, it’s a button<br />ImageView, ImageButton: support for images<br />CheckBox, RadioButton, RadioGroupare a few common UI widgets<br />http://greenoid.blogspot.com (Oct 2010)<br />
  8. 8. Sample Code For the Lazy<br />package com.droid.clockwork;<br />import android.app.Activity;<br />import android.os.Bundle;<br />import android.widget.TextView;<br />import java.util.Date;<br />public class MainClock extends Activity {<br />/** Called when the activity is first created. */<br /> public void onCreate(Bundle icicle) {<br />super.onCreate(icicle);<br />TextViewtv = new TextView(this);<br />tv.setText("The Time Now Is: "+new Date().toString());<br />setContentView(tv);<br /> }<br />}<br />http://greenoid.blogspot.com (Oct 2010)<br />
  9. 9. Coming soon Part 3/6<br />http://greenoid.blogspot.com (Oct 2010)<br />Meanwhile checkout our blog: http://greenoid.blogspot.com<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×