> Hello everyone. I'm trying to make a list of options, where each item in > this list is an image followed by a text. I'm rather new to Android and > couldn't find what is the most suitable Adapter (and most important, how > to > use it) for this task. Can anyone help me with this? With a very simple > example, if possible.
Your choice of adapter is largely driven by where your data is coming from. If it is an array inside your application, use ArrayAdapter. If the data is represented by a Cursor from a ContentProvider, use SimpleCursorAdapter. And so on. In terms of creating list entries more complicated than a single bit of text, I recommend creating a subclass of the adapter and overriding getView(), so you control what View objects are used for the rows in the list. To build those views, you can either just create the appropriate Java objects (e.g., LinearLayout, TextView, ImageView) and wire them together, or you can create a separate layout XML file and use ViewInflate to build your Java widgets for you. We had a couple of threads on this in early May; here's a link to one: http://groups.google.com/group/android-developers/browse_thread/thread/355d3cdfa1c787b8 In terms of a "simple" example...well...most tend not to be that simple. You can look at samples/ApiDemos/src/com/google/android/samples/view/List6.java in your SDK, though that one builds a whole adapter class rather than just overriding an existing one, and it does not use ViewInflate. Most of the List*.java series of files in that directory have implementations of getView(). There might be a simple example out on anddev.org, too. You could download the source code for my not-yet-formally-announced book (http://commonsware.com/Android/) and take a look at TourListActivity in the TourIt sample. That has a lot of other stuff in there tied to locations and mapping, but it does show a list with custom list entry layouts built via ViewInflate. Hope this helps! -- Mark Murphy (a Commons Guy) http://commonsware.com _The Busy Coder's Guide to Android Development_ -- Available Now! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

