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

Community
  • 1
  • 1
Chloe
  • 149
  • 1
  • 12
  • Can you post the error you are getting? – Niko Jan 28 '14 at 08:19
  • Serious? just change sum.setArguments(bundle); to sum.setArguments(dataBundle); :) – alex Jan 28 '14 at 08: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 – Chloe Jan 28 '14 at 08:21
  • @alex opps, i forgotten to change . However ,after I change back ,it still have redline on the setArguments – Chloe Jan 28 '14 at 08:21

4 Answers4

3

Intent class has no setArguments function on android.

Check this on here.

agastalver
  • 1,036
  • 8
  • 13
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);
owe
  • 4,890
  • 7
  • 36
  • 47
  • I've changed, but there's a red line over setARguments – Chloe Jan 28 '14 at 08:20
  • 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 – Chloe Jan 28 '14 at 08:22
  • 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. – owe Jan 28 '14 at 08:24
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".

ZhangYu
  • 31
  • 1
  • 2
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.

Community
  • 1
  • 1
alex
  • 5,516
  • 2
  • 36
  • 60