Shivputra. N
Shivputra. N

Reputation: 1

How to use Bundle Method in android?

I am creating an quiz app, after answering all the question in main.xml layout I want to show the result in report.xml as output.

I am not able to refer setContentView(R.layout.main) and setContentView(R.layout.report)in Main.java, then I heard about Bundle that we can pass the value in it and use it in another Activity. I tried a lot but I could'nt make it.

Upvotes: 0

Views: 493

Answers (1)

Lokesh
Lokesh

Reputation: 5368

Use this code to send multiple data from one activity to other

done.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                namevalue=name.getText().toString();
                overvalue=over.getText().toString();
                audiostatus=audio.getText().toString();
                Intent intent=new Intent(Settings.this,home.class);
                 Bundle bundle = new Bundle();   
                 bundle.putString( "namevalue",namevalue);  
                 bundle.putString("overvalue",overvaluse);
                 bundle.putInt("value",variablename);
                 intent.putExtras(bundle);   
                 startActivity(intent);                 
                }
            });

And also follow this link http://congeritc.blogspot.in/2012/04/android-passing-values-between-views.html

Upvotes: 1

Related Questions