-3

I have here a array list containing of Integers

static List<Integer> var_Pposition = new ArrayList<>();

I try this like so, But there's error tells

Intent in = new Intent(merchandise.this, PurchasedViewCart.class);
in.putExtra("item_position", var_Pposition); // Cannot resolve method 'putExtra(java.lang.String, java.util.List<java.lang.Integer>
V-rund Puro-hit
  • 5,418
  • 9
  • 29
  • 50
Raffy T Lawrence
  • 275
  • 1
  • 6
  • 18
  • 7
    Possible duplicate of [Intent.putExtra List](http://stackoverflow.com/questions/6543811/intent-putextra-list) – Mrinmoy Jan 25 '17 at 04:35

4 Answers4

3

Pass to intent as follows:

Intent intent = new Intent(merchandise.this, PurchasedViewCart.class);  
intent.putIntegerArrayListExtra("myList", (ArrayList<Integer>) var_Pposition );

Retrieve data as follows:

ArrayList<Integer> test = getIntent().getIntegerArrayListExtra("myList");
Rjz Satvara
  • 3,453
  • 2
  • 24
  • 47
1

Put to intent

Intent intent = new Intent(merchandise.this, PurchasedViewCart.class);  
intent.putIntegerArrayListExtra("myList", (ArrayList<Integer>) var_Pposition );  

Get from intent

ArrayList<Integer> test = getIntent(). putIntegerArrayListExtra("myList");
Rajesh Panchal
  • 1,062
  • 3
  • 20
  • 38
0

You would call the putExtra (String name, Serializable value) of Intent to store, and getSerializableExtra (String name) for retrieval.

Example:

List<Integer> var_Pposition = new ArrayList<>();
intent.putExtra("var_Pposition", var_Pposition);

In the other Activity:

List<Integer> var_Pposition = (ArrayList<Integer>) getIntent().getSerializableExtra("var_Pposition");
Athul
  • 791
  • 6
  • 16
0

try this,

   static ArrayList<Integer> var_Pposition = new ArrayList<>()

Intent doesn't have putExtra with List parameter. you have to do like,

   intent.putIntegerArrayListExtra("myList", var_Pposition);

or you need to cast it

Noorul
  • 3,259
  • 2
  • 31
  • 46