dimanche 19 juillet 2015

How can I share data between a checkbox/radiogroup and textview in two different activities on eclipse?

I need to put a list of items in different pages that can be selected through checkboxes and radio buttons and the overall price (addition of each selected item) should be added to the main page. How can I do this?

here's my code for the main page:

package com.example.mcdonalds;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.CheckBox;

public class MenuPage extends Activity {

private static final String CheckBox = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_menu_page);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_page, menu);
    return true;
}
public void gotoBeefPage(View view) {
    Intent intent1 = new Intent(this,BeefPage.class);
    startActivity(intent1);
}
public void gotoChickenPage(View view) {
    Intent intent2 = new Intent(this,ChickenPage.class);
    startActivity(intent2);
}
public void gotoKidsMenu(View view) {
    Intent intent3 = new Intent(this,KidsMenu.class);
    startActivity(intent3);
}
public void gotoDessertPage(View view) {
    Intent intent4 = new Intent(this,DessertPage.class);
    startActivity(intent4);
}

and here's a code for one of the pages that contains checkboxes:

package com.example.mcdonalds;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.CheckBox;

public class BeefPage extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_beef_page);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.beef_page, menu);
    return true;
}       




Aucun commentaire:

Enregistrer un commentaire