erturne wrote:
> I'm working on my first Android app, and would appreciate any guidance
> to make sure I'm doing this the best way. Basically I want an Activity
> to list recipes. Eventually I'll have another Activity to display an
> individual recipe selected from the list, but I'm not worrying about
> that yet. I apologize if this is a really noob question!
> 
> The list of recipes should show each recipe's title, description,
> rating, and date added. For each recipe in the list I'd like the title
> on the top left of the list entry, rating on the top right,
> description on the bottom left, and date added on the bottom right. I
> may want to add photo, icons representing properties of the recipe
> (e.g. vegetarian), etc. The makes me think that each item in the list
> should be a TableLayout.
> 
> With all that in mind, here's what I'm planning to write:
> 
> 1. Write class RecipesDataAdapter extends BaseAdapter. Override the
> getView() method to return an instance of TableLayout. Populate each
> instance of TableLayout with two TableRows, the first row containing
> cells for title and rating, and the second row containing cells for
> description and date added. For now I'll just pass the Recipe
> instances to the adapter in an array.
> 
> 2. Write class ListRecipesActivity that extends ListActivity. Override
> the onCreate() method to obtain instances of the Recipe class and call
> the setListAdapter() method with an instance of the RecipesDataAdapter
> class.
> 
> Notice that all this is done in code without any layout XML files. All
> the examples of Activities that I've seen use a layout XML file and
> call setContentView(R.layout.layout_name) but I'm not sure if I need
> to do that for this, or even how I would do that considering my main
> Activity is a list of non-trivial things (TableLayout).
> 
> Please let me know if you think I'm on the right track, or if there is
> a better way to approach this problem.

You definitely want to use layout XML files for your rows and your
activity, to make it easier to support different screen sizes and
orientations. Otherwise, in a quick read, what you have here seems OK.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in US: 14-18 June 2010: http://bignerdranch.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to