icons do not display in the LunchList example

4 views
Skip to first unread message

oregonduckman

unread,
Dec 29, 2009, 8:52:38 PM12/29/09
to cw-android
I using Eclipse to implement the code in Tutorial 5 and it is not
clear to me how RestaurantAdapter.getView(...) is ever called. I can
see how a row is added in onClick but there does not seem to be a
direct call to getView anywhere in the code, can someone point me in
the right direction?

Mark Murphy

unread,
Dec 29, 2009, 9:11:39 PM12/29/09
to cw-an...@googlegroups.com
oregonduckman wrote:
> I using Eclipse to implement the code in Tutorial 5 and it is not
> clear to me how RestaurantAdapter.getView(...) is ever called.

Android calls it. More accurately, ListView calls it when it needs rows.

> I can
> see how a row is added in onClick but there does not seem to be a
> direct call to getView anywhere in the code, can someone point me in
> the right direction?

Read _The Busy Coder's Guide to Android Development_, Version 2.8,
Chapter 8 ("Getting Fancy With Lists"). It covers the entire process.

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

Warescription: Three Android Books, Plus Updates, $35/Year

oregonduckman

unread,
Dec 30, 2009, 10:23:29 AM12/30/09
to cw-an...@googlegroups.com
Thanks for the info. I found the problem in my code that prevented the icons from being displayed.

On page 34 you introduce the usage of the adapter with it's allocation as adapter=new ArrayAdapter<Restaurant>(this,android.R.layout.simple_list_item_1,model) with associated remarks in the text that appears in the paragraph previous to the code. Then on page 43 the same line of code appears as adapter=new RestaurantAdapter(); without any explanation (that I could find).

In future revisions it may be helpful to explain to the reader why the above mentioned line of code was changed.


--

You received this message because you are subscribed to the Google Groups "cw-android" group.
To post to this group, send email to cw-an...@googlegroups.com.
To unsubscribe from this group, send email to cw-android+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cw-android?hl=en.



Mark Murphy

unread,
Dec 30, 2009, 10:38:26 AM12/30/09
to cw-an...@googlegroups.com
oregonduckman wrote:
> Thanks for the info. I found the problem in my code that prevented the
> icons from being displayed.
>
> On page 34 you introduce the usage of the adapter with it's allocation
> as adapter=new
> ArrayAdapter<Restaurant>(this,android.R.layout.simple_list_item_1,model)
> with associated remarks in the text that appears in the paragraph
> previous to the code. Then on page 43 the same line of code appears
> as adapter=new *RestaurantAdapter*(); without any explanation (that I
> could find).

That is covered on pages 37-38, Tutorial 5 ("Making Our List Be Fancy"),
Step #1 ("Create a Stub Custom Adapter").

In particular:

"We also need to change our data member to be a RestaurantAdapter, both
where it is declared and where it is instantiated in onCreate()."

Now, that's not the clearest, and I will improve that sentence in the
next release, due out tomorrow.

I apologize for any confusion.

Android Consulting/App Development: http://commonsware.com/consulting

oregonduckman

unread,
Dec 30, 2009, 1:39:38 PM12/30/09
to cw-an...@googlegroups.com
Yes I see the text your are talking about on page 38, thanks for
pointing it out.

Reply all
Reply to author
Forward
0 new messages