0

I would like to make this code at serialazble

But I dk why, in the setArguments, there is a red underline, thus can't run the code.

Can someone guide me?

 public void summaryClick (View v) { Intent sum = new Intent(this, summary.class); fuelLogPojo clickedObject = pojoArrayList.get(0); Bundle dataBundle = new Bundle(); dataBundle.putString("clickedID", clickedObject.getid()); dataBundle.putString("clickedDate", clickedObject.getdate()); dataBundle.putString("clickedPrice", clickedObject.getprice()); dataBundle.putString("clickedPump", clickedObject.getpump()); dataBundle.putString("clickedCost", clickedObject.getcost()); dataBundle.putString("clickedOdometer", clickedObject.getodometer()); dataBundle.putString("clickedpreOdometer", clickedObject.getpreodometer()); dataBundle.putString("clickedFCon", clickedObject.getfcon()); dataBundle.putSerializable("pojoArrayList", pojoArrayList); Log.i("FuelLog", "dataBundle " + dataBundle); // Attach the bundled data to the intent // sum.putExtras(dataBundle); sum.setArguments(dataBundle); // Start the Activity startActivity(sum); } 

take reference from here passing a list of data from one intent to another using serializable

4
  • Can you post the error you are getting? Commented Jan 28, 2014 at 8:19
  • Serious? just change sum.setArguments(bundle); to sum.setArguments(dataBundle); :) Commented Jan 28, 2014 at 8:19
  • @Niko there is a redline over the over the word setArguements. I hover over it, and was told to add cast to sum.I've follow the instruction, but still redline Commented Jan 28, 2014 at 8:21
  • @alex opps, i forgotten to change . However ,after I change back ,it still have redline on the setArguments Commented Jan 28, 2014 at 8:21

4 Answers 4

3

Intent class has no setArguments function on android.

Check this on here.

Sign up to request clarification or add additional context in comments.

1 Comment

@Chloe Test putExtras, maybe it's what you want.
0

You don't declare any variable as bundle. Your Bundle is called dataBundle.

Change this line:

sum.setArguments(bundle); 

to:

sum.putExtra("my data bundle", dataBundle); 

3 Comments

I've changed, but there's a red line over setARguments
I can't run the project, because it contains error. Like I say, there's a red line over the word setARgument that don't allow me to run the project
as AdolAurion says, there is no such method. I checked the API and edit my answer. Try this and tell me if it's working.
0

Why do you think an Intent (sum here) has a method "setArguments"? So far as i know the setArgument is a method of "Fragment". If you want to set bundle into an Intent, try "putExtras".

Comments

0

Replace the red line with this:

sum.putExtras(dataBundle); 

Intent does'nt have a function called setArguments(Bundle bundle). Have a look at the documentation here.

For a complete example, have a look at this post.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.