0

So I have this code and it is working. My problem is that how can I pass and show the result in new activity. I set the onclick of the 3 checkbox with selectItinerary

public class topPawikan extends ActionBarActivity {
ArrayList<String> selection = new ArrayList<String>();
TextView final_text;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.toppawikan);

    final_text = (TextView)findViewById(R.id.textView);
    final_text.setEnabled(false);
}

public void selectItinerary(View view){
boolean checked = ((CheckBox) view).isChecked();
    switch (view.getId())
    {
        case R.id.checkBox1:

            if (checked)
            {selection.add("Maglibot");}

            else
            {selection.remove("Maglibot");}

            break;


        case R.id.checkBox2:

            if (checked)
            {selection.add("Kumain");}

            else
            {selection.remove("Kumain");}

            break;

        case R.id.checkBox3:

            if (checked)
            {selection.add("Umupo");}

            else
            {selection.remove("Umupo");}

            break;

    }
}

//button
public void finalSelection(View view){
String final_itinerary = "";

    for (String Selections : selection)
    {
        final_itinerary = final_itinerary + Selections + "\n";
    }
    final_text.setText(final_itinerary);
    final_text.setEnabled(true);
}
}
Lal
  • 14,505
  • 4
  • 39
  • 63
Newbee
  • 87
  • 1
  • 2
  • 6
  • Possible duplicate of [How do I pass data between activities in Android?](http://stackoverflow.com/questions/2091465/how-do-i-pass-data-between-activities-in-android) – Mage Xy Oct 15 '15 at 19:00

1 Answers1

0

Put params into the new Intent. Start new activity on button click.

Intent intent = new Intent(topPawikan.this, SecondActivity.class);
Bundle b = new Bundle();
b.putString("selection", final_text.getText().toString()); 
intent.putExtras(b); 
startActivity(intent);

Then get the params in your new Activity:

Bundle b = getIntent().getExtras();
String selection = b.getString("selection");
Hasanaga
  • 1,030
  • 1
  • 7
  • 17
  • there's a problem in the line b.putInt("selection", final_text.getText().toString()); 'putInt(java.lang.String, int)' in 'android.os.BaseBundle' cannot be applied to '(java.lang.String, java.lang.String)' – Newbee Oct 16 '15 at 04:06