将选中的复选框值带到其他页面

时间:2014-09-27 08:56:37

标签: java android eclipse checkbox

我目前正在使用eclipse开发移动应用程序。现在o面临将检查复选框带到新页面的问题......

这是复选框页面的代码......

页面名称:mcpakej1.xml

  `  <?xml version="1.0" encoding="utf-8"?>

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"    
    android:layout_centerHorizontal="true"
     tools:context="com.example.mobilecatering.MainActivity" >

   <ScrollView
    android:layout_width="match_parent"
     android:layout_height="match_parent" >

      <LinearLayout
       android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

    <CheckBox
         android:id="@+id/pakejA1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView2"
         android:layout_below="@+id/textView2"

      <CheckBox
         android:id="@+id/pakejA2"
         android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/nasiputih1"
    android:layout_below="@+id/nasiputih1"
    android:text="Nasi Beriyani" />

    <CheckBox
    android:id="@+id/pakejA3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/nasiberiyani1"
    android:layout_below="@+id/nasiberiyani1"
    android:text="Nasi Minyak" />

     <CheckBox
    android:id="@+id/pakejA4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView3"
    android:layout_below="@+id/textView3"
    android:text="Ayam Masak Kurma" />

     <CheckBox
    android:id="@+id/pakejA5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/ayamkurma1"
    android:layout_below="@+id/ayamkurma1"
    android:text="Ayam Masak Lemak" />

      <CheckBox
    android:id="@+id/pakejA6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/ayamlemak1"
    android:layout_below="@+id/ayamlemak1"
    android:text="Ayam Kari" />


      <CheckBox
    android:id="@+id/pakejA7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/ayamkari1"
    android:layout_below="@+id/ayamkari1"
    android:text="Ayam Rendang" />

     <CheckBox
    android:id="@+id/pakejA8"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/ayamrendang1"
    android:layout_below="@+id/ayamrendang1"
    android:text="Ayam Masak Merah" />

     <CheckBox
    android:id="@+id/pakejA9"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView4"
    android:layout_below="@+id/textView4"
    android:text="Perut Air Asam" />


     <CheckBox
    android:id="@+id/pakejA10"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/perutairasam1"
    android:layout_below="@+id/perutairasam1"
    android:text="Daging Masak Tomato" />


      <CheckBox
    android:id="@+id/pakejA11"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/dagingtomato1"
    android:layout_below="@+id/dagingtomato1"
    android:text="Daging Masak Singgang" />

 <CheckBox
    android:id="@+id/pakejA12"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/dagingsinggang1"
    android:layout_below="@+id/dagingsinggang1"
    android:text="Daging Masak Merah" />


<CheckBox
    android:id="@+id/pakejA13"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView5"
    android:layout_below="@+id/textView5"
    android:text="Kerabu Taugeh" />


<CheckBox
    android:id="@+id/pakejA14"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/kerabutaugeh1"
    android:layout_below="@+id/kerabutaugeh1"
    android:text="Pindang Kacang Panjang" />


<CheckBox
    android:id="@+id/pakejA15"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/pindangkacang1"
    android:layout_below="@+id/pindangkacang1"
    android:text="Jelatah" />

<CheckBox
    android:id="@+id/pakejA16"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/jelatah1"
    android:layout_below="@+id/jelatah1"
    android:text="Dalca Sayur" />


<CheckBox
    android:id="@+id/pakejA17"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/dalcasayur1"
    android:layout_below="@+id/dalcasayur1"
    android:text="Papadom" />

     <CheckBox
    android:id="@+id/pakejA18"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView6"
    android:layout_below="@+id/textView6"
    android:text="Kari Ikan" />


     <CheckBox
    android:id="@+id/pakejA19"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/pakejA18"
    android:layout_below="@+id/kariikan1"
    android:text="Kari Ikan Masin dan Nenas" />

    <CheckBox
    android:id="@+id/pakejA20"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView7"
    android:layout_below="@+id/textView7"
    android:text="Sirap Ais" />


    <CheckBox
    android:id="@+id/pakejA21"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/sirapais1"
    android:layout_below="@+id/sirapais1"
    android:text="Oren" />


     <CheckBox
    android:id="@+id/pakejA22"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/pakejA21"
    android:layout_below="@+id/pakejA21"
    android:text="Teh Tarik" />


    <CheckBox
    android:id="@+id/pakejA23"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView8"
    android:layout_below="@+id/textView8"
    android:text="Agar - Agar" />

    <CheckBox
    android:id="@+id/pakejA24"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/agaragar1"
    android:layout_below="@+id/agaragar1"
    android:text="Bubur Kacang Hijau" />

     <CheckBox
    android:id="@+id/pakejA25"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/buburkacanghijau1"
    android:layout_below="@+id/buburkacanghijau1"
    android:text="Kuih Muih" />   

        <ImageButton
        android:id="@+id/gobutton"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_alignTop="@+id/homebtn"
        android:layout_toRightOf="@+id/homebtn"
        android:background="@drawable/gobutton"
        android:onClick="goReceipt" />

         </LinearLayout>


      </ScrollView></RelativeLayout>`

这是java中的过程。 页面名称:mcpakej1.java

     `package com.example.mobilecatering;


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

       public class mcpakej1 extends Activity 
       {

        CheckBox nsPutih,nsBeriyani,nsMinyak,aymKurma,aymLemak,aymKari,aymRendang,aymMerah,prtAsam, dggTomato, dggSinggang, dggMerah,kerabuTaugeh, pindangKacang,jelatah,dalcaSayur,papadom,kariIkan,ikanMasin, sirapAis, oren,tehTarik,agarAgar, buburKacang,kuih;

       public void onCreate(Bundle savedInstanceState) 
      {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.mcpakej1);


      nsPutih       = (CheckBox) findViewById(R.id.pakejA1);
      nsBeriyani    = (CheckBox) findViewById(R.id.pakejA2);
      nsMinyak      = (CheckBox) findViewById(R.id.pakejA3);
      aymKurma      = (CheckBox) findViewById(R.id.pakejA4);
      aymLemak      = (CheckBox) findViewById(R.id.pakejA5);
      aymKari       = (CheckBox) findViewById(R.id.pakejA6);
      aymRendang    = (CheckBox) findViewById(R.id.pakejA7);
      aymMerah      = (CheckBox) findViewById(R.id.pakejA8);
      prtAsam       = (CheckBox) findViewById(R.id.pakejA9);
      dggTomato     = (CheckBox) findViewById(R.id.pakejA10);
      dggSinggang   = (CheckBox) findViewById(R.id.pakejA11);
      dggMerah      = (CheckBox) findViewById(R.id.pakejA12);
      kerabuTaugeh  = (CheckBox) findViewById(R.id.pakejA13);
      pindangKacang = (CheckBox) findViewById(R.id.pakejA14);
      jelatah       = (CheckBox) findViewById(R.id.pakejA15);
      dalcaSayur    = (CheckBox) findViewById(R.id.pakejA16);
      papadom       = (CheckBox) findViewById(R.id.pakejA17); 
      kariIkan      = (CheckBox) findViewById(R.id.pakejA18);
      ikanMasin     = (CheckBox) findViewById(R.id.pakejA19);
      sirapAis      = (CheckBox) findViewById(R.id.pakejA20);
      oren          = (CheckBox) findViewById(R.id.pakejA21);
      tehTarik      = (CheckBox) findViewById(R.id.pakejA22);
      agarAgar      = (CheckBox) findViewById(R.id.pakejA23);
      buburKacang   = (CheckBox) findViewById(R.id.pakejA24);
      kuih          = (CheckBox) findViewById(R.id.pakejA25);

     }

public void goHome(View v){
{
    Intent intent = new Intent(v.getContext(), MainActivity.class);
    startActivityForResult(intent,0);}
}

public void goReceipt(View v) 
{
    Intent intent = new Intent(v.getContext(), doReceipt.class);

    intent.putExtra("nsBeriyani", nsBeriyani.isChecked());
    intent.putExtra("nsPutih", nsPutih.isChecked());
    intent.putExtra("nsMinyak", nsMinyak.isChecked());
    intent.putExtra("aymKurma", aymKurma.isChecked());
    intent.putExtra("aymKari", aymKari.isChecked());
    intent.putExtra("aymRendang", aymRendang.isChecked());
    intent.putExtra("aymMerah", aymMerah.isChecked());
    intent.putExtra("prtAsam", prtAsam.isChecked());
    intent.putExtra("dggTomato", dggTomato.isChecked());
    intent.putExtra("dggSinggang", dggSinggang.isChecked());
    intent.putExtra("dggMerah", dggMerah.isChecked());
    intent.putExtra("kerabuTaugeh", kerabuTaugeh.isChecked());
    intent.putExtra("pindangKacang", pindangKacang.isChecked());
    intent.putExtra("jelatah", jelatah.isChecked());
    intent.putExtra("dalcaSayur", dalcaSayur.isChecked());
    intent.putExtra("papadom", papadom.isChecked());
    intent.putExtra("kariIkan", kariIkan.isChecked());
    intent.putExtra("ikanMasin", ikanMasin.isChecked());
    intent.putExtra("sirapAis", sirapAis.isChecked());
    intent.putExtra("oren", oren.isChecked());
    intent.putExtra("tehTarik", tehTarik.isChecked());
    intent.putExtra("agarAgar", agarAgar.isChecked());
    intent.putExtra("buburKacang", buburKacang.isChecked());
    intent.putExtra("kuih", kuih.isChecked());
    startActivityForResult(intent,0);
    }
 }`

用户点击按钮id goButton后,此页面将执行此过程。

page name = doReceipt.java

       package com.example.mobilecatering;

    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TextView;

    public class doReceipt extends Activity

    {
     boolean nsPutih, nsBeriyani,nsMinyak,aymKurma,aymLemak,aymKari,aymRendang,aymMerah,prtAsam, dggTomato, dggSinggang, dggMerah,kerabuTaugeh, pindangKacang,jelatah,dalcaSayur,papadom,kariIkan,ikanMasin, sirapAis, oren,tehTarik,agarAgar, buburKacang,kuih;

      TextView tvOutput;

     public void onCreate(Bundle savedInstanceState) 
       {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.receipt);

      tvOutput = (TextView) findViewById(R.id.textView1);
      tvOutput = (TextView) findViewById(R.id.textView2);
      tvOutput = (TextView) findViewById(R.id.textView3);
      tvOutput = (TextView) findViewById(R.id.textView4);
      tvOutput = (TextView) findViewById(R.id.textView5);
      tvOutput = (TextView) findViewById(R.id.textView6);
      tvOutput = (TextView) findViewById(R.id.textView7);
      tvOutput = (TextView) findViewById(R.id.textView8);
      tvOutput = (TextView) findViewById(R.id.textView9);
      tvOutput = (TextView) findViewById(R.id.textView10);
      tvOutput = (TextView) findViewById(R.id.textView11);
      tvOutput = (TextView) findViewById(R.id.textView12);
      tvOutput = (TextView) findViewById(R.id.textView13);
      tvOutput = (TextView) findViewById(R.id.textView14);
      tvOutput = (TextView) findViewById(R.id.textView15);
      tvOutput = (TextView) findViewById(R.id.textView16);
      tvOutput = (TextView) findViewById(R.id.textView17);
      tvOutput = (TextView) findViewById(R.id.textView18);
      tvOutput = (TextView) findViewById(R.id.textView19);
      tvOutput = (TextView) findViewById(R.id.textView20);
      tvOutput = (TextView) findViewById(R.id.textView21);
      tvOutput = (TextView) findViewById(R.id.textView22);
      tvOutput = (TextView) findViewById(R.id.textView23);
      tvOutput = (TextView) findViewById(R.id.textView24);
      tvOutput = (TextView) findViewById(R.id.textView25);


      Bundle data = this.getIntent().getExtras();

      nsPutih=data.getBoolean("nsPutih");
      nsBeriyani=data.getBoolean("nsBeriyani");
      nsMinyak=data.getBoolean("nsMinyak");
      aymKurma=data.getBoolean("aymKurma");
      aymLemak=data.getBoolean("aymLemak");
      aymKari=data.getBoolean("aymKari");
      aymRendang=data.getBoolean("aymRendang");
      aymMerah=data.getBoolean("aymMerah");
      prtAsam=data.getBoolean("prtAsam");
      dggTomato=data.getBoolean("dggTomato");
      dggSinggang=data.getBoolean("dggSinggang");
      dggMerah=data.getBoolean("dggMerah");
      kerabuTaugeh=data.getBoolean("kerabuTaugeh");
      pindangKacang=data.getBoolean("pindangKacang");
      jelatah=data.getBoolean("jelatah");
      dalcaSayur=data.getBoolean("dalcaSayur");
      papadom=data.getBoolean("papadom");
      kariIkan=data.getBoolean("kariIkan");
      ikanMasin=data.getBoolean("ikanMasin");
      sirapAis=data.getBoolean("sirapAis");
      oren=data.getBoolean("oren");
      tehTarik=data.getBoolean("tehTarik");
      agarAgar=data.getBoolean("agarAgar");
      buburKacang=data.getBoolean("buburKacang");
      kuih=data.getBoolean("kuih");




      if(nsPutih==true)
      {

          tvOutput.setText("Nasi Putih");

      }

      if (nsBeriyani==true)
      {
          tvOutput.setText("Nasi Beriyani");
      }

      if (nsMinyak==true)
      {
          tvOutput.setText("Nasi Minyak");
      }

      if(aymKurma==true)
      {
          tvOutput.setText("Ayam Masak Kurma");
      }

      if (aymLemak==true)
      {
          tvOutput.setText("Ayam Masak Lemak");
      }

      if (aymKari==true)
      {
          tvOutput.setText("Ayam Masak Kari");
      }

      if (aymRendang==true)
      {
          tvOutput.setText("Ayam Masak Rendang");
      }

      if (aymMerah==true)
      {
          tvOutput.setText("Ayam Masak Merah");
      }

      if (prtAsam==true)
      {
          tvOutput.setText("Perut Air Asam");
      }

      if (dggTomato==true)
      {
          tvOutput.setText("Daging Masak Tomato");
      }

      if (dggSinggang==true)
      {
          tvOutput.setText("Daging Masak Singgang");
      }

      if (dggMerah==true)
      {
          tvOutput.setText("Daging Masak Merah");
      }

      if (kerabuTaugeh==true)
      {
          tvOutput.setText("Kerabu Taugeh");
      }

      if (pindangKacang==true)
      {
          tvOutput.setText("Pindang Kacang");
      }

      if (jelatah==true)
      {
          tvOutput.setText("Jelatah");
      }

      if (dalcaSayur==true)
      {
          tvOutput.setText("Dalca Sayur");
      }

      if (papadom==true)
      {
          tvOutput.setText("Papadom");
      }

      if (kariIkan==true)
      {
          tvOutput.setText("Kari Ikan");
      }

      if (ikanMasin==true)
      {
          tvOutput.setText("Kari Ikan Masin");
      }

      if (sirapAis==true)
      {
          tvOutput.setText("Sirap Ais");
      }

      if (oren==true)
      {
          tvOutput.setText("Oren");
      }

      if (tehTarik==true)
      {
          tvOutput.setText("Teh Tarik");
      }

      if (agarAgar==true)
      {
          tvOutput.setText("Agar Agar");
      }

      if (buburKacang==true)
      {
          tvOutput.setText("Bubur Kacang");
      }

      if (kuih==true)
      {
          tvOutput.setText("Kuih Muih");
      }
    }

    }

这是选中复选框应显示文字的页面... 页面名称:receipt.xml

      <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
     android:layout_height="match_parent" >

      <ScrollView
     android:layout_width="match_parent"
     android:layout_height="match_parent" >

     <LinearLayout
       android:layout_width="match_parent"
       android:layout_height="match_parent"
        android:orientation="vertical" >



     <TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="14dp"
    android:layout_marginTop="62dp"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/textView1"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView2"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView3"
    android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/textView4"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView5"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView7"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView6"
    android:textAppearance="?android:attr/textAppearanceMedium" />

      <TextView
    android:id="@+id/textView8"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/textView7"
    android:textAppearance="?android:attr/textAppearanceMedium" />

   <TextView
    android:id="@+id/textView9"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView8"
    android:textAppearance="?android:attr/textAppearanceMedium" />

      <TextView
    android:id="@+id/textView10"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView9"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView11"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView10"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView12"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/textView11"
    android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
    android:id="@+id/textView13"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView12"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView14"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView13"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView15"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/textView14"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView16"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView15"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView17"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView16"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView18"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView17"
    android:textAppearance="?android:attr/textAppearanceMedium" />

      <TextView
    android:id="@+id/textView19"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView18"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView20"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView19"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView21"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView20"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView22"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView21"
    android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
    android:id="@+id/textView23"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView22"
    android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
    android:id="@+id/textView24"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView23"
    android:textAppearance="?android:attr/textAppearanceMedium" />

     <TextView
    android:id="@+id/textView25"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView24"
    android:textAppearance="?android:attr/textAppearanceMedium" />


   </LinearLayout>


      </ScrollView></RelativeLayout>

当我运行eclipse的模拟器时,即使我选中了许多复选框,页面的receipt.xml也只显示1个复选框值。

帮助plz .... tq

我勾选复选框Ayam Masak kurma和daging masak merah .... 输出变成这样......

Ayam Masak Kurma

Daging Masak Merah

那里有很多空间......你可以帮助我......我无法在这里上传模拟器的图像......它说我必须得到10分才能发布图像....

2 个答案:

答案 0 :(得分:0)

文字视图之间的空白区域是未隐藏的文字视图,当您没有数据时会尝试隐藏它们,如:

    if(nsPutih==true) {
        tvOutput1.setText("Nasi Putih");
        tvOutput1.setVisibility(View.VISIBLE);
    } else {
        tvOutput1.setVisibility(View.GONE);
    }

然而,这是不好的做法,您应该尝试通过将它们放在ListView中来动态创建textview。还尝试使用对象Map将数据传递给活动。

答案 1 :(得分:-1)

有了你的意图尝试使用putextra和getextra方法传递你的值,它将起作用