我是安卓新手。
如何使用 Intent 将数组值从一个类获取到另一个类?
我试过这样......第一次活动......
Intent videointent = new Intent(Focusarea.this,Videoplayer.class); videointent.putExtra("string-array", resim_list); startActivity(videointent);
第二次活动
Intent intent=getIntent(); String [] Array = intent.getStringArrayExtra("string-array");
我将此作为警告,我将 null 作为第二秒活动中的值..
W/Bundle(521): Key string-array expected String[] but value was a java.util.ArrayList. The default value <null> was returned. W/Bundle(521): Attempt to cast generated internal exception: W/Bundle(521): java.lang.ClassCastException: java.util.ArrayList W/Bundle(521): at android.os.Bundle.getStringArray(Bundle.java:1459) W/Bundle(521): at android.content.Intent.getStringArrayExtra(Intent.java:3630) W/Bundle(521): at com.example.TEENEINSTIEN.Videoplayer.onCreate(Videoplayer.java:20) W/Bundle(521): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)