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 7953777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:14:03+00:00 2026-06-04T03:14:03+00:00

hi im getting a problem on my checkbox when check is change and if

  • 0

hi im getting a problem on my checkbox when check is change and if the checkbox is checked im displaying a alert dialog which take a input value and set the value to the text view and also im adding that value to the List here is my code

    @Override
    public void onCheckedChanged(CompoundButton checkBox, boolean isChecked)
    {
        TextView tvItem=(TextView)selectedView.findViewById(R.id.foodName); 
        final TextView tvQuantity=(TextView)selectedView.findViewById(R.id.quantity);

        orderList=new ArrayList<Order>();
        Order order=new Order();
        if(isChecked)
        {   

            final AlertDialog.Builder quantityAlert= new AlertDialog.Builder(TakeOrder.this);
            quantityAlert.setTitle("Quantity");
            quantityAlert.setMessage("Please enter quantity");

            final EditText input = new EditText(TakeOrder.this);
            input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
            quantityAlert.setView(input);

            quantityAlert.setPositiveButton("Ok", new DialogInterface.OnClickListener()
            {   
                public void onClick(DialogInterface dialog, int whichButton)
                {
                  value = input.getText();

                  tvQuantity.setText(value);

                }               
            });

            quantityAlert.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
            {
                  public void onClick(DialogInterface dialog, int whichButton)
                  {

                  }
                });

            quantityAlert.show();

            order.setItem(tvItem.getText().toString());
            order.setQuantity(Integer.valueOf(tvQuantity.getText().toString()));

            orderList.add(selectedPosition, order);
            Log.v("Item:",orderList.get(selectedPosition).getItem());
            Log.v("Quantity:",String.valueOf(orderList.get(selectedPosition).getQuantity()));
        }
        else
        {
            tvQuantity.setText("0");
            orderList.remove(selectedPosition);

        }




    }

The problem is that im showing the alert dialog first then taking the value of quantity from user but before i enter the value in alert box the Log.v executes and shows 0 that means in my List quantity is being added to 0…
but i want that the quantity value coming from alert dialog should be added to the List….
Can any one please help me…

  • 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-04T03:14:03+00:00Added an answer on June 4, 2026 at 3:14 am

    This makes sense becuase the code doesn’t stop and wait for your Alert Dialog to finish. It builds it, displays it, then moves on, which is where you are creating the value and adding it to the list.

    If you want it to only add when you press “Ok”, you need to put the Order modification and insertion code inside your “Ok” (positive button) handler.

    public void onClick(DialogInterface dialog, int whichButton)
    {               
        Order order=new Order();         
        value = input.getText();                      
        tvQuantity.setText(value);                       
    
        order.setItem(tvItem.getText().toString());             
        order.setQuantity(Integer.valueOf(value);
    
        orderList.add(selectedPosition, order);    
    
        Log.v("Item:",orderList.get(selectedPosition).getItem());             
        Log.v("Quantity:",String.valueOf(orderList.get(selectedPosition).getQuantity()));         
    } 
    

    I also put the Order intialization statement inside the onClick method because it isn’t used anywhere else. Save yourself one line of code if they select “Cancel” 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to have php determines whether a checkbox is checked, but I
I have list view [text view and check box controlls] with more data. I
I have list view [text view and check box controlls] with more data. I
I have a listview in which I am getting values from base adapter.what I
I'm having problem getting all the values in datalist here is the problem: I
I'm getting this problem: PHP Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable
I am having a problem with getting my JQuery javascript code to apply to
I'm currently struggling on getting my CheckBox es to properly center within my GridViewColumn
I keep getting stuck on this one little thing. I append a checkbox and
Interesting problem. In a project scope change, I broke one application into two applications.

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.