« Episode 3 - Analyse This | Main | Episode 1 - >You Are Here< »
Wednesday
Mar092011

Episode 2 - Feed Me!

Java 101


Java is a platform independent language that runs compiled code on a Java Virtual Machine(JVM).

Object-oriented with some procedural elements, similar to:

  • C++, C#, VB, Python



Object-Oriented-Programming: An object is an entity that represents either a real world object or and abstract concept. Objects have both data and behaviour. Example, A Book object would carry data like the author, titile, and publisher. At the same time it would have behaviours like getTitle that would tell you the books title.

Java has type checking, meaning that all data must have a type, for example text must be of the String type or numbers must be an integer, float, etc.

Memory Management is a feature of Java that you can safely ignore for the first little while. When you create an object it is given a place in memory, when it is no longer needed, the Evil Java Garbage Collector comes along and repossesses it.


Java Syntax Example:

1 public class MeaningOfLife {
2
3 public int getMeaningOfLife() {
4
5 int meaning_of_life = 40 + 2;
6
7 return meaning_of_life;
8 }
9 }


Java Keywords: public, private, return, class, etc...

Declaration Statements(Variables): String example = “Hello Android!”;


Primitive/Wrapped and Reference Types


Great Books To Buy!

- Head First Java -
http://oreilly.com/catalog/9780596004651
- Android Application Development - 24hrs - Conder & Darcy - http://www.amazon.com/dp/0321673352?tag=mamlambo-20
- Android Wireless Application Development -
http://www.amazon.com/Android-Wireless-Application-Development-Conder/dp/0321627091
- Professional Android 2 Application Development -
http://www.amazon.com/gp/product/0470565527?ie=UTF8
- Learn Java for Android Development -
http://www.amazon.com/Learn-Java-Android-Development-Friesen/dp/1430231564/ref=pd_sim_b_5


Feed Me! - Parsing XML/RSS Feed Data Tutorial

  1. Add Internet Permission to AndroidManifest.xml as we will be downloading an xml file from the internet.

  2. Create a layout that includes a ListView to display the RSS Feed information. ListViews are a great way to display itemized data.

  3. Create an Activity (MainActivity.java) to handle the UI layout and to fill the ListView with data once it is parsed.

  4. Use an ASyncTask thread to handle downloading and parsing the RSS Feed in the background so we avoid locking up the UI thread.

  5. Create a custom object to represent our items, in this case “Episodes”. The episode class must include all properties that we will be pulling out of our RSS feed and must have Getters and Setters to access them.

  6. Create a class to handle parsing the RSS XML Feed (XmlFeedParser.java). We will be using the Android class XmlPullParser to parse our content. There are many different parsers available but this one is easiest to understand.

  7. Create a layout xml file for our row items for the ListView (episode_row.xml).

  8. Once our feed is parsed and we have returned an ArrayList of Episodes, we can display the information in the ListView. This is done with a ListAdapter with the type ArrayAdapter. Fill out the constructor with a Context, row layout file, TextView ID, and ArrayList of titles.

 


Greg Gets Fancy - Custom ListViews

http://www.androidpatterns.com/uap_category/dealing-with-data

Designing a custom ListView is always a good idea - it will keep your application fresh and not plain like others - stay away from the black/gray schemes.

  • For the RSS feed data - it’s good to design the ListViews with the same color scheme as the app itself

  • A suggestion is to alternate colors in the list - usually a light & darker ones

  • Keep the size of the ListView not too big - font appropriate - do some testing to get it right

  • Create thumbnails for the RSS feed - small - give them some space

  • You can design a small mask around the thumbnails for style

  • Designing a nice background will help make your lists stand out

  • An option is to make your lists transparent so the background will show through - (AndroidTO twitter keyword feed) (Background+CacheColorHint+ListSelector=#00000000,

  • Keep the highlight color (onPress) a contrasting color to the bg color (ListSelector in XML Properties)

  • Tab Bars - it’s good to design custom tabs & icons for your app (Twitter)

  • Always give the user a notification that data is loading - small animation (ProgressBar) (talk about both kinds)

  • Use animations to drill down into the data - slide to the right (LayoutAnimationController)

 

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>