Click here to Skip to main content
15,919,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sales_info);
        
         ed_unitprice=(EditText)findViewById(R.id.ed_unitprice);
		 dt_orderdate=(DatePicker)findViewById(R.id.dt_orderdate);
		 Spin_prdct = (Spinner)findViewById(R.id.spin_prdct);
		 Spin_cust_name_sales=(Spinner)findViewById(R.id.Spin_cust_name_sales);
		 Spin_uom=(Spinner)findViewById(R.id.Spin_uom);
		 btn_nxt_order=(Button)findViewById(R.id.btn_nxt_order);
}


public void onClick(View  v)
	 {
		 int day = dt_orderdate.getDayOfMonth();
		 int month = dt_orderdate.getMonth();
		 int year = dt_orderdate.getYear();
		 String ans= String.valueOf(year)+String.valueOf(month)+String.valueOf(day);
		 
		 String[] prdct=Spin_prdct.getSelectedItem().toString().replace("|", ",").split(",");
		 String[] name=Spin_cust_name_sales.getSelectedItem().toString().replace("|", ",").split(",");
		 String[] uom=Spin_uom.getSelectedItem().toString().replace("|", ",").split(",");

		 //this is ArrayList(Bundle) arr4 = new ArrayList(Bundle)
                 // i donot know why its not showing this <> so i use this() in place of <> only in this question otherwise its ok in eclipse
		 ArrayList<bundle> arr4 = new ArrayList<bundle>();
			 
		 		 
		 Intent myintent=new Intent(SalesInfo.this,Orderconform.class);
		 Bundle bnd=new Bundle();
		 bnd.putSerializable("temp", arr4);
		 
		 bnd.putString("ed_unitprice", ed_unitprice.getText().toString());
		 bnd.putString("ans", ans.toString());
		 bnd.putString("Spin_prdct", prdct[0].toString());
		 bnd.putString("Spin_cust_name_sales",name[0].toString());
		 bnd.putString("Spin_uom", uom[0].toString());
		 arr4.add(bnd);
		 myintent.putExtras(bnd);
		 SalesInfo.this.startActivity(myintent);
		 }

Qestion1: Is this correct way to store value in arraylist(bundle)??
Question2: How can I retrieve this arraylist(bundle) in another activity??
Question3: How can I show this arraylist in datagridview??

Note: I am very new to android please tell me the answers very clearly please
Posted
Updated 10-Oct-12 6:12am
v2
Comments
ridoy 10-Oct-12 15:39pm    
Use bundleName.putStringArraylist() to sender activity and then use bundleName.getStringArraylist() to receiver activity.
Ravi Bhavnani 15-Oct-12 11:56am    
Unless I'm mistaken, it seems you're adding the ArrayList to the Bundle and the Bundle to the ArrayList. Did you intend to do that?

1 solution

The accepted way to pass an object from one activity to another is to ensure that it implements Parcelable. See this[^] SO answer for sample code.

/ravi
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900