0

I am trying to pass selected items from two spinners in second activity textview, it works with one spinner but when i add second application stops working. Here is my code for first activity:

public void addListenerOnButton() {

        final Context context = this;`enter code here`

        button = (Button) findViewById(R.id.button4);

        s2 = (Spinner) findViewById(spinner2);
        s1=(Spinner) findViewById(R.id.spinner1);
        button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {

                Intent intent = new Intent(getApplicationContext(), Activity2.class);


                Bundle b = new Bundle();


                b.putString("rg", s2.getSelectedItem().toString());
                b.putString("tpi",s1.getSelectedItem().toString());


                intent.putExtras(b);


                startActivity(intent);


            }

        })

And this is my code for second activity:

Bundle b = getIntent().getExtras();
 registracija.setText(b.getCharSequence("rg"));
        vreme.setText(b.getCharSequence("tpi"));

0 Answers0