Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8575531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:42:55+00:00 2026-06-11T19:42:55+00:00

Currently, I’ve been involved in an android app development related to online foodItem ordering.

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:42:56+00:00Added an answer on June 11, 2026 at 7:42 pm
    int total=0;
    
    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";
    
                         total+=myMenulist.get(i).price;
    
                    }
    
    
                }
                Log.e("menu","Items "+selected);
                Toast.makeText(getApplicationContext(), selected, Toast.LENGTH_SHORT).show();
    
    
            }
        });
    

    Now on button click event get total.

    button.setOnClickListenernew View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
    
                Toast.makeText(
                        this,
                        ""+total,
                        Toast.LENGTH_LONG).show();
    
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

currently, I`m implementing a map App with Mono4Droid and there I`m using a WebView
Currently i have a node.js and socket.io application in development on my local machine
Currently we are using Trac . Tickets are good for tracking tasks and related
Currently, before merging a branch, I use the following commands to see what changes
Currently I am trying to make my app available for iOS4, to increase the
Currently I have the following code to update the NSLevelindicator: [self.headerIndicator selfFloatValue:heightValue] Is there
Currently I am working in message compose screen in Android, Using Intent to show
Currently, my Perl output is hard-coded to dump into the following Unix directory: my
Currently i am working simple PayPal integration in Android, So i set the Manifest.xml
Currently in my webpage i load images to the ListView object as follows... <ContentTemplate>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.