简体   繁体   中英

Best way to approach Invoice Listing into Multi-Column ArrayList?

I have created a SQLite DB, in this DB is a whole wack of invoices, each invoice has a customer ID or supplier ID depending on if the invoice is a sale or an expense respectively.

Basically, what I am trying to do is query the DB, grab a list of all invoices by whatever customer ID or supplier ID is selected, and display all the invoices for this customer or supplier in a multi-column listview. I have already created the multi-column listview, it is driven by an xml template for each row which is basically a linearlayout with 4 textview's, one for each column.

This being said, there are 4 values from each invoice I would like to populate the listview with. I assume that if I create an ArrayList, add each invoice as it's own row (also an array of the 4 values I need per invoice), I will get a nice and easy multi-dimensional ArrayList that I can simply loop through to populate the listview.

Before I dive into the code, I want to ensure this is the best approach, perhaps there is a method I am missing? I was surprised I couldn't find multi-column listviews, so you never know!

Thanks!

If your ListView is meant to show items from a SQLite DB you want to write a CursorAdapter instead of reading the whole result set into an ArrayList. CursorAdapters can display each row from a query efficiently and help you easily reflect any changes to the backing data that happen while the user is viewing it.

You may also be interested in this Google I/O talk that goes over the basics of ListView: http://www.google.com/events/io/2010/sessions/world-of-listview-android.html

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