jamesmuskett / newWeather

my 1st go at an android app
0 stars 0 forks source link

Create a ListView #5

Closed vaughandroid closed 9 years ago

vaughandroid commented 9 years ago

http://developer.android.com/guide/topics/ui/layout/listview.html

Hint: Use one of these: http://developer.android.com/reference/android/widget/ArrayAdapter.html Don't worry about Loaders & Cursors for now.

vaughandroid commented 9 years ago

As discussed, suggest you take things in this order:

  1. Use a pre-defined array of city names.
  2. Get the onClick events working to launch a new activity and pass the city name.
  3. Start using a custom view for the list items. I think if you include a TextView in your layout you can just swap it for the default one (you will need to pass in the id of your TextView too).
  4. Create your own Adapter by extending ArrayAdapter and overriding the getView() method. Find examples of this online or in the LR project to see how to recycle/inflate the view as needed.
  5. Use a more complicated data type to provide the data for the ListView (this will be the generic type of the ArrayAdapter). Probably a City class? This should be straightforward now that you've overriden getView()!
vaughandroid commented 9 years ago

Done in #6 :smile: