Currently, I've been involved in an android app development related to online foodItem ordering. I've a listView with following schema:
itemName1 itemPrice1 checkBox
itemName2 itemPrice2 checkBox
itemName3 itemPrice3 checkBox
.
.
.
GetYourCart[Button]
My task is to keep track of each of the selected itemNames with price and total price when the user presses the button. I've used the SparseBooleanArray sbArray = myMenulist.getCheckedItemPositions(); but it's not showing any result.
How can I implement this? I've gone through several questions asked in stackoverflow and other online tutorials but can't get it.
Edited: Here is the code for selected items that I used to check the result:
btnyourCart.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
String selected = "";
int cntChoice = myMenulist.getCount();
SparseBooleanArray sbArray = myMenulist.getCheckedItemPositions();
for(int i=0;i<cntChoice;i++){
if(sbArray.get(i)) {
selected += myMenulist.getItemAtPosition(i).toString() + "\n";
}
}
Log.e("menu","Items "+selected);
Toast.makeText(getApplicationContext(), selected, Toast.LENGTH_SHORT).show();
}
});
Thanks in advance!