Re: [android-developers] Re: ListView and ListAdapter
John Gaby wrote: I am writing a c++ wrapper for the Java. Oy. In the environment I am talking about, the ListView is created via a call from a c++ module. Double oy. However, on the Java side, I can see the ListView and it's adapter being created. I can see calls to the adapter, and as I said, I get a call to the getCount and I can see that it returns 3. I get calls to the other methods I mentioned, and they all return the appropriate numbers. However, the getView method is never called at all, and the list appears empty. If I had to guess, your ListView is not being added to any parent, so there is no need for it to ever call getView() on the adapter. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.5 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: ListView and ListAdapter
John Gaby wrote: I don't believe that is the case, since I can set a background color on the ListView, and I can see it at the location and size that was specified. So much for that theory. Also, if I stop using my custom ListAdapter and substitute one that just displays a simple list of strings, it works fine. There is one puzzling aspect, however. When it displays my list it draws it with the greyish bar at the bottom which I usually see when the list has more items than can fit and can be scrolled. However, it should have only 3 items and not be scrollable. Also, I do not see the little scroll bar to the right. Does this give you any clue as to what might be going on? No, but you might want to crank up hierarchyviewer and see what it tells you. For example, it will clearly indicate if you have any rows, how big they are, etc. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Online Training: 21-25 June 2010: http://onlc.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: ListView and ListAdapter
John Gaby wrote: Thanks much for your help. The hiearchyviewer is a NICE tool of which I was unaware. Unfortunately it simply shows that my ListView has no children (rows). I believe I have discovered the problem, however, and am able to reproduce it with a pure Java application. It seems that if I call the 'setAdapter' method AFTER I have place the ListView into it's parent, then it doesn't work. I actually had not initially done that, but I needed a way for the ListView to refresh after I changed it's contents. It SEEMED that if I reset the adapter that it would then ask me for the data again (it does ask for the count), but clearly this does not work. So the real question is how do I tell the ListView to reload the data after I have changed the data that underlies the ListAdapter. If your ListAdapter extends ArrayAdapter, you could use add(), insert(), and remove() on the adapter itself to affect your changes, in which case it will automatically call notifyDataSetChanged(). If your ListAdapter extends CursorAdapter, call requery() on the Cursor, and that will automatically ripple out to the ListView. At worst, call notifyDataSetChanged() on the ListAdapter. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Development Wiki: http://wiki.andmob.org -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: ListView and ListAdapter
John Gaby wrote: I have based my adapter on ListAdapter which does not seem to have a notifyDataSetChanged method. Use BaseAdapter as your base class. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.0 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en