Hi want to create a custom cursor adapter so I can display an image with 2 lines of text. I have had some trouble understanding the custom cursor adapters but I do not understand how to add an imageview to be filled from the path in my database.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
Will,
I've actually implemented something incredibly similar to what you are looking for. Here is my implementation.
XML just incase...
This displays two rows of text and up to 2 images to the right of the text depending on certain conditions.
I hope this can give you a basis to work from!
Good luck :]
Here is a great tutorial that I have used before to help with my custom list adapters. It sounds like it is doing the exact same thing you want to do. The tutorial shows how to build a custom list adapter with an image and two lines of text.
Adding images and text is not specific to
CursorAdapter
; you use the same technique for any kind of adapter. You can create a layout for your row and inflate it inside yourgetView
method. The APIDemos sample project, contained in the Android SDKandroid-sdk-PLATFORM/samples/android-XY/ApiDemos
folder, does what you want. You can find the row definitons inlist_item_icon_text.xml
. Here is copy of file content (w/o the license).Check what I have done: BTW:
CheckpointsView.getImageResId()
returns a valid drawable referenceAnd the XML just in case
You can check the whole code at: http://code.google.com/p/droidtimesheet/