简体   繁体   中英

Accessing the view for a row in an Android ListActivity with a SimpleCursorAdapter

I have a ListActivity that's populated with a SimpleCursorAdapter which pulls the data from a database. I want to set images on the rows at runtime based on the data in the database. If the data is a one, I want a filled-in icon, and if it is 0, I want it to be hollow.

In order to do this, I figured it would be easiest to access the layout of each row individually, and change the image, but I can't figure out how to access the individual rows without clicking on them.

I also eventually want the image itself to have a separate click event from the row it's on, but I'll probably ask another question for that.

While 100rabh's link did help me construct better searches which helped me answer the question, the answer I needed was that I needed to build my own custom cursorAdapter which I just extended from SimpleCursorAdapter.

The setViewImage(ImageView v, String value) method helped, although I also did a bit of customization on bindImage to handle all of my cases for the various lists I used this for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM