0

friends.I am new in android developement plz help me. I want to pass my array arrayItemName of string to next activity and display it on next activity on button click.

@Override
public void onClick(View v)
{
    // TODO Auto-generated method stub
  Intent intent = new Intent(MakeOrder.this,ConfirmOrder.class);
  String []arrayItemName=itemName.split("\\,");
  for(int i=0;i<arrayItemName.length;i++)
  {
   intent.putExtra("My_Array_ItemName",arrayItemName[i].toString());
  }
  startActivity(intent);
}

3 Answers 3

3

Try:

Bundle bundle = new Bundle();
bundle.putStringArray(key, new String[]{value1, value2});
Intent mIntent = new Intent(context, Class);
mIntent.putExtras(bundle );

And on the receiver side:

Bundle bundle = getIntent().getExtras();
String[] array = bundle.getStringArray(key);
Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

 intent.putExtra("My_Array_ItemName", arrayItemName);
 startActivity(intent);

 ....

 Bundle extras = getIntent().getExtras();
 String[] arr = extras.getStringArray("My_Array_ItemName");

Comments

0

Try this:

Bundle b=new Bundle();
b.putStringArray(key, new String[]{value1, value2});
Intent i=new Intent(context, Class);
i.putExtras(b);

Hope this will help you.

In order to read:

if you nee to display the values after button click. you put the below code into onclick method

Bundle b=this.getIntent().getExtras();
String[] array=b.getStringArray(key);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.