What I want: I have a listview which lists all the entries of my sqlite database. The database contains all the items that a number of people have bought at a supermarket, so the listview displays all the items in the database. Now, an item can be shared by many users (infact the app is about to split the costs of a receipt) and I want that the names of who are going to shared that particular item must be displayed under that item in the listview.
Result using cursoradapter in a common way:
1) row1 item quantity price
2) row2 item quantity price
3) row3 item quantity price
4) ...
Resul I want:
1) row1 item quantity price
name 1
name 2
2) row2 item quantity price
name 4
name 7
3) row3 item quantity price
name 2
4) ...
name rows are the textviews(http://pastebin.com/hzLPPV6B) I want do add
What I have tried to do:
- bindView method of my CursorAdapter http://pastebin.com/4839LMq3
- layout where the listview is http://pastebin.com/uVhy3GqN
- layout of the single item in the listview http://pastebin.com/srsm7SRS
- layout of the textviews(with the name) to add under the right item in the list view http://pastebin.com/hzLPPV6B
What the problem is: The problem is that the bindview method doesn't work as I expected and the app starts to display infinite(I think) number of person name textview(3rd pastebin link) under each item in the list(not only the persons names I wanted).
This is the that part of the code inside bindView which I am not sure about:
LinearLayout itemBuyersLinearLayout = (LinearLayout) view.findViewById(R.id.itemBuyersReceipt);
ArrayList<String> buyersName = dbManager.getBuyersNameOfItem(receiptId, cursorAdapter.getItemId(cursor.getPosition()));
for (int i=0;i<buyersName.size();i++) {
itemBuyersLinearLayout.addView(getLayoutInflater().inflate(R.layout.receipt_item_buyer_receipt, itemBuyersLinearLayout, false));
TextView buyerNameTextView = (TextView) itemBuyersLinearLayout.findViewById(R.id.itemBuyerReceipt);
buyerNameTextView.setText(buyersName.get(i));
}
I don't know what I have to do/where I need to add some code to add that extra information
Aucun commentaire:
Enregistrer un commentaire