2015-04-30 94 views
-1

我得到这个错误:ArrayList中传递到另一个活动的Android

Error

在行,其中我想提出的ArrayList ..

我在做什么错?

我的代码:

List<Integer> skatlice = Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 

    ... 

    if (cases[position] == 1) { 
     myIntent2 = new Intent(Game.this, Skatle.class); 
     vrednostskatel = 1; 
     myIntent2.putExtra("vrednostskatel", vrednostskatel); 

     skatlice.set(0, 1); 
     myIntent2.putIntegerArrayListExtra("skatlice", ArrayList<Integer> skatlice); 

     startActivity(myIntent2); 
     overridePendingTransition(R.layout.mainfadein, R.layout.splashfadeout); 
} 
+0

你应该删除的ArrayList在此行中 'myIntent2.putIntegerArrayListExtra( “skatlice”,ArrayList的 skatlice);' 它看起来像 'myIntent2.putIntegerArrayListExtra( “skatlice”,skatlice); ' – Apple

+0

@Apple然后我得到这个错误:类型意图中的方法putIntegerArrayListExtra(String,ArrayList )不适用于参数(字符串,列表) – ribicincc

+1

我认为您应该将您的列表转换为ArrayList,您应该放回ArrayList 但用括号和括号括起来。它看起来像这样 'myIntent2.putIntegerArrayListExtra(“skatlice”,(ArrayList )skatlice);' – Apple

回答

0

语法不正确,改变

myIntent2.putIntegerArrayListExtra("skatlice", ArrayList<Integer> skatlice); 

myIntent2.putIntegerArrayListExtra("skatlice", (ArrayList<Integer>) skatlice); 
0

你必须创建一个可变的列表(ArrayList中)从不变列表skatlice。使用此:

intent.putIntegerArrayListExtra("skatlice", new ArrayList<>(skatlice)); 
相关问题