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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:59:48+00:00 2026-06-18T00:59:48+00:00

I have made an app in which i am using Two Tabs , First

  • 0

I have made an app in which i am using Two Tabs,

First Tab, to show list of Products [Menu Tab]

Second Tab, to show products added by you [Cart Tab]

Here i am allowing user to add products to cart, update quantity for product and show total amount of all the Items.

In my code i am facing very small problem but i am not getting any way for last two days to resolve this.

Problem:

Whenever i do click on Cart Tab to view products, those i have selected to buy and then again move back to Menu Tab to select few more products to buy and then again do click on Cart Tab to view all products i have selected, Here i am able to view Selected Product but not able to view updated quantity and not getting any change in Total Amount [Getting total of all previous added items only, not for those i have added second time…]

Please tell me where i am missing, to get updated quantity and to get change in total price, what code i need to add and where i need to add in my ViewCartActivity class

ViewCartActivity.Java:

    public class ViewCartActivity extends Activity {

    TextView mTxtViewGrandTotal;
    String mGrandTotal ;


    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.viewcartactivity);

        ListView mLstView1 = (ListView) findViewById(R.id.listView1);
        mTxtViewGrandTotal = (TextView) findViewById(R.id.mTxtViewGrandTotalValue);

        ViewCartAdapter mViewCartAdpt = new ViewCartAdapter(ViewCartActivity.this);
        mLstView1.setAdapter(mViewCartAdpt);

        if (Constants.mItem_Detail.size() > 0) 
        {
            Double mGTotal = Double.parseDouble(Constants.mItem_Detail.get(0).get(SingleProductActivity.KEY_TOTAL));
            for (int i = 1; i < Constants.mItem_Detail.size(); i++) {   
                mGTotal = mGTotal + Double.parseDouble(Constants.mItem_Detail.get(i).get(SingleProductActivity.KEY_TOTAL));
            }

            mGrandTotal = String.valueOf(mGTotal);
            mTxtViewGrandTotal.setText(mGrandTotal);



            ImageButton mImgViewCart = (ImageButton) findViewById(R.id.back_btn);
            mImgViewCart.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    // TODO Auto-generated method stub

                        Intent mViewCartIntent = new Intent(ViewCartActivity.this, com.version.bajrang.january.menu.ArrowsActivity.class);
                        startActivity(mViewCartIntent);


                }
            });     
        }
    }   

    @Override
    protected void onResume() {
    // TODO Auto-generated method stub
    System.out.println("onResume list current size "+Constants.mItem_Detail.size());
    super.onResume();
    }
}

In Logcat, i am getting:

onResume list current size 3 [Number of Records]

TabActivity.Java:

    private void setTabs()
{
    addTab("Order", R.drawable.tab_order, CategoryActivity.class);
    addTab("Cart", R.drawable.tab_cart, ViewCartActivity.class);
}

@Override
    public void onBackPressed() {
    // Code to update product Quantity
    super.onBackPressed();
    Constants.mItem_Detail.clear();
}

ViewCartAdapter.Java:

 public class ViewCartAdapter extends BaseAdapter {

Activity activity;
LayoutInflater inflater;

public ViewCartAdapter(Activity a) {
    // TODO Auto-generated constructor stub
    activity = a;
    inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
    // TODO Auto-generated method stub
    return Constants.mItem_Detail.size();
}
public Object getItem(int position) {
    //return position;
    return Constants.mItem_Detail.get(position);
}
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;

}
public View getView(final int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    View vi = convertView;
    if (convertView == null)
        vi = inflater.inflate(R.layout.viewcartlist, null);
    TextView title = (TextView) vi.findViewById(R.id.title);
    TextView qty = (TextView) vi.findViewById(R.id.qty);
    TextView cost = (TextView) vi.findViewById(R.id.cost);

    HashMap<String, String> item = new HashMap<String, String>();
    item = Constants.mItem_Detail.get(position);
    // Setting all values in listview
    title.setText(item.get(SingleProductActivity.TAG_NAME));
    qty.setText(item.get(SingleProductActivity.KEY_QTY));
    cost.setText(item.get(SingleProductActivity.TAG_DURATION));
    return vi;
}   
   }
  • 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-18T00:59:48+00:00Added an answer on June 18, 2026 at 12:59 am

    Rakesh you have written everything needed in your program, just need to move from onCreate() to onResume() Method in ViewCartActivity

    Like this:

     public class ViewCartActivity extends Activity 
     {
    
    TextView mTxtViewGrandTotal;
    String mGrandTotal ;
    
    
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.viewcartactivity);
    
        ListView mLstView1 = (ListView) findViewById(R.id.listView1);
        mTxtViewGrandTotal = (TextView) findViewById(R.id.mTxtViewGrandTotalValue);
    
        ViewCartAdapter mViewCartAdpt = new ViewCartAdapter(ViewCartActivity.this);
        mLstView1.setAdapter(mViewCartAdpt);
    
            ImageButton mImgViewCart = (ImageButton) findViewById(R.id.back_btn);
            mImgViewCart.setOnClickListener(new OnClickListener() 
            {
    
                public void onClick(View v) {
                    // TODO Auto-generated method stub
    
                        Intent mViewCartIntent = new Intent(ViewCartActivity.this, com.version.bajrang.january.menu.ArrowsActivity.class);
                        startActivity(mViewCartIntent);
    
                }
            });     
        }
    
    
    @Override
    protected void onResume() 
    {
        super.onResume();
        System.out.println("onResume list current size " + Constants.mItem_Detail.size());
    
        if (Constants.mItem_Detail.size() == 0) 
        {
        return;
        }
    
        Double mGTotal = Double.parseDouble(Constants.mItem_Detail.get(0).get(SingleProductActivity.KEY_TOTAL));
        for (int i = 1; i < Constants.mItem_Detail.size(); i++) 
        {   
            mGTotal = mGTotal + Double.parseDouble(Constants.mItem_Detail.get(i).get(SingleProductActivity.KEY_TOTAL));
        }
        mGrandTotal = String.valueOf(mGTotal);
        mTxtViewGrandTotal.setText(mGrandTotal);
         }
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Ripple which im using to test app made for android. App is
I have made an app which uses DropBox SDK for iPhone to connect to
I have made an iPhone App which has a loginwithFacebook button , the login
I have made an android app which working fine. I implemented the Login functionality
I have made a layout for my app which uses a lot of activities.
I have two objects a user and a role which I make persistant using
Suppose I have have made a an osX app without using Xcode. After compiling
I have this little test-case which is supposed to show two widgets, with one
I'm coding a web app for Document Managers using jQtouch and have made a
I have a .NET 4 app which consists of the app and two class

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.