-4

我正在开发一个收集用户选择(来自复选框)并将其发送到新活动(按下按钮时)的应用程序。在新的活动中,将收集一个新的数据(editText),并将接收到的数据+新收集的数据合并并通过电子邮件发送。

当我按下第一个按钮将复选框数据发送到新活动时,出现错误:

应用程序意外停止

这是代码:

 public void onClick(View v) 
{

                   cakeDataformated();
                   // to convert the data (checkBox) to a string
                   String fianlformatedData = cakeDataformated();

                    Intent i = new Intent(this, PersonData.class);  
                    i.putExtra("cakedata", fianlformatedData);
                    startActivity(i);

    }

复选框转换方法为:

 public String cakeDataformated () {
    // TODO Auto-generated method stub

    boolean checkyStatus1 = checky1.isChecked();
    boolean checkyStatus2 = checky2.isChecked();
    boolean checkyStatus3 = checky3.isChecked();
    boolean checkyStatus4 = checky4.isChecked();
            // to read the checkbox data
    String form = finalFormUsingFollowing (checkyStatus1 ,checkyStatus2 ,checkyStatus3 , checkyStatus4 );
        //  to convert the check box response into a message and save it as 
            //  a string called form
            // example : cakes selected are : cake1 , cake3 
    return form ;


}

所以,如果有任何错误,请告诉我。

4

1 回答 1

1
RadioGroup radioGroup = (RadioGroup) this
            .findViewById(R.id.radio_group);
    radioGroup
            .setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(RadioGroup radioGroup, int id) {
                    final RadioButton radioButton = (RadioButton) radioGroup
                            .findViewById(id);

                    String selectedText = radioButton.getText().toString();
                    Intent i = new Intent(this, PersonData.class);
                    i.putExtra("cakedata", selectedText);
                    startActivity(i);
                }

            });
于 2013-10-27T01:31:29.540 回答