i am trying to make a shopping cart app, allowing user to choose category then select item to purchase, once user will click on any item to purchase, then showing that selected item into another activity with item image, name, cost, qty (to accept by user) and also providing add to cart functionality, now i want whenever user will click on Add to Cart button, then selected item need to show in ViewCart Activity, so here i am placing my AddtoCart Activity code, please tell me what i need to write to show added item(s) into ViewCart Category just like in shopping cart, In ViewCart activity i just want to show item title, cost and qty (entered by user):-
public class AddtoCart extends Activity{
static final String KEY_TITLE = "title";
static final String KEY_COST = "cost";
static final String KEY_THUMB_URL = "imageUri";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.single);
Intent in = getIntent();
String title = in.getStringExtra(KEY_TITLE);
String thumb_url = in.getStringExtra(KEY_THUMB_URL);
String cost = in.getStringExtra(KEY_COST);
ImageLoader imageLoader = new ImageLoader(getApplicationContext());
ImageView imgv = (ImageView) findViewById(R.id.single_thumb);
TextView txttitle = (TextView) findViewById(R.id.single_title);
TextView txtcost = (TextView) findViewById(R.id.single_cost);
txttitle.setText(title);
txtcost.setText(cost);
imageLoader.DisplayImage(thumb_url, imgv);
// Save a reference to the quantity edit text
final EditText editTextQuantity = (EditText) findViewById(R.id.edit_qty);
ImageButton addToCartButton = (ImageButton) findViewById(R.id.img_add);
addToCartButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Check to see that a valid quantity was entered
int quantity = 0;
try {
quantity = Integer.parseInt(editTextQuantity.getText()
.toString());
if (quantity <= 0) {
Toast.makeText(getBaseContext(),
"Please enter a quantity of 1 or higher",
Toast.LENGTH_SHORT).show();
return;
}
} catch (Exception e) {
Toast.makeText(getBaseContext(),
"Please enter a numeric quantity",
Toast.LENGTH_SHORT).show();
return;
}
// Close the activity
finish();
}
});
}}