And one more question. If I define my own plain XML resource like in my post above, what about the localization? Would I put the xml file in "values" and later "values-DE" and it would work just like with the strings?
On Aug 9, 7:37 am, gnugu <rho...@gmail.com> wrote: > Hi Mark, > thanks for your response, I was hoping to catch your attention ;). > > I know and am inheriting ArrayAdapter and overriding getView(). > > May be I should rephrase my question. > > I know how to put it all together from the UI side. I know how to > populate the list view. > > What I don't know is how to describe data that will be used to > populate the list view. I want the data to be described in XML > resource. > > For example, if my list item only had one TextView in it, i.e. I only > need to display item title I would use <string-array> as a resource, > inflate it in my code and feed it to ArrayAdapter. > The thing is that I want three pieces of data per item. One ugly way > of doing it would be to have two string arrays defined in resources > and one typed array. String arrays would be for title and summary and > typed array would be for icons. But that's ugly and can go out of sync > quickly. > > I'm now thinking of defining just my own plain XML resource and use > Resources.getXml() to get XmlResourceParser and parse it myself. The > question is, if my xml looks something like this: > > <item icon="@drawable/myIco" title="foo" summary="bar" /> > > how do I access that @drawable/myIco resource (not the icon attribute) > while parsing the XML? > > Thanks. > > On Aug 8, 5:41 pm, Mark Murphy <mmur...@commonsware.com> wrote: > > > > > On Sun, Aug 8, 2010 at 8:00 PM, gnugu <rho...@gmail.com> wrote: > > > as I stated in my original post I already have created custom layout > > > with and ImageView and two TextViews. > > > > The question at hand is: > > > How do I populate a ListView, that has a custom list item as defined > > > above, from XML resource? > > > > I.e.: Having a custom layout with ImageView and two TextViews, how can > > > I define the content in XML resource? > > > If you are using ArrayAdapter, you will need to create a subclass and > > override getView(): > > >http://stackoverflow.com/questions/3436322/multiple-icons-in-android-... > > > If you are using SimpleCursorAdapter, you can use a ViewBinder, or > > subclass the adapter and override setViewImage(), or subclass the > > adapter and override newView() and bindView(). > > > And so on. > > > -- > > Mark Murphy (a Commons > > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy > > > _The Busy Coder's Guide to Android Development_ Version 3.1 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