I currently have a ListView which is populated from items within an SQLite database. I'm wondering if there is a way to add titles to the ListView.
Currently my listview looks like this:
However, I would ideally like the listview to look (somewhat) like this:
My current code for generating the listview is:
//DECLARE ARRAYS FOR LIST VIEW
String[] stockNames = new String[] {stockDbManager.itemID, stockDbManager.itemName, stockDbManager.itemDesc, stockDbManager.itemQuantity};
int[] viewStockNames = new int[] {R.id.itemIdLayout, R.id.itemNameLayout, R.id.itemDescLayout, R.id.itemQuantityLayout };
//DEFINE CURSOR (CALLING METHOD FROM STOCKDBMANAGER CLASS, PASSING ITEM ID
Cursor specificSearch = stockDatabase.returnString(itemName);
//DEFINE LIST ADAPTER FOR PRINTING RESULT TO LIST
final ListAdapter specificAdapterList = new SimpleCursorAdapter(
this, //CONTEXT OF ADAPTER (THIS ACTIVITY)
R.layout.databaselistlayout, //DEFINE LAYOUT USING XML FILE
specificSearch, //CURSOR TO USE, DEFINED ABOVE
stockNames, //ARRAY OF COLUMN NAMES
viewStockNames //ARRAY OF ROWS
);
//DISPLAY RESULTS IN LIST
stockList.setAdapter(specificAdapterList);
I have tried adding text to the string array like this, however this doesn't work at all:
String[] stockNames = new String[] {"itemID: "+stockDbManager.itemID, "item Name: "+stockDbManager.itemName, "item Desc: "+stockDbManager.itemDesc, "item Quantity: "+stockDbManager.itemQuantity};
Thanks for taking the time to read this, hopefully there is a solution!
Aucun commentaire:
Enregistrer un commentaire