Issue With Passing A Custom Arraylist Through Intent With Serialize
I am attempting to pass an array List of Custom objects through from one class to the other. I used a wrapper class to pass over the array List: package perks; import java.io.Seri
Solution 1:
You are passing player.perks
which is an ArrayList
of Perk
and in your other activity you are getting PerkWrapper
and hence it is giving you error.You will need to do something like this
ArrayList<Perk> perks = (ArrayList<Perk>) getIntent().getSerializableExtra("perks");
Solution 2:
Reply to @amit singh's Answer (My reputation not yet upto comment level)
The method specified is possible possible only for arraylist of the format ArrayList. For custom objects, this is not applicable.
Solution 3:
To pass arraylist between activities, use-
Intent intent = newIntent(this, secondActivity.class);
intent.putStringArrayListExtra("list", samplelist);
startActivity(intent);
In your receiving intent you need to do:
Intenti= getIntent();
stock_list = i.getStringArrayListExtra("list");
Post a Comment for "Issue With Passing A Custom Arraylist Through Intent With Serialize"