• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps display listview from database

aloha1

Lurker
Hi, I would like to get data from an external database where each row displayed on my android phone would be formatted differently depending on the content from the database. Would it make sense to use a cursor adapter or a custom adapter? Thanks, Aaron
 
Thanks hvsent. I'm using MySQl which queries using a php script and then outputs Json. It then puts the Json into a hash map. If I already have the data in a hash map would I then iterate through it and use a case statement to choose a custom view? If so where should I put that logic? In the onCreate function or elsewhere?

Here you go, this should get you off in the right path.
http://www.journaldev.com/10416/android-listview-with-custom-adapter-example-tutorial
I don't know how to change the row based off content of the item. I would guess to use a switch statement and a identifier so you can check the id and then adjust the layout based off the id programatically.
Here you go, this should get you off in the right path.
http://www.journaldev.com/10416/android-listview-with-custom-adapter-example-tutorial
I don't know how to change the row based off content of the item. I would guess to use a switch statement and a identifier so you can check the id and then adjust the layout based off the id programatically.
 
Back
Top Bottom