传递类中传递对象的代码
final ArrayList<SongDetails> Songinfo = getSongsFromDirectory(f);
public void onItemClick(AdapterView a, View v, int position, long id) {
Intent intent = new Intent(getActivity(), NowPlaying.class);
intent.putExtra("Data1",songinfo);
intent.putExtra("Data2",position);
startActivity(intent);
}
});
检索类中的代码
Intent i = getIntent();
ArrayList<SongDetails> Songinfo2 = (ArrayList<SongDetails>)i.getSerializableExtra("Data1");
position=i.getIntExtra("Data2", 1);
我已经在两个类以及 SongDetails 类中实现了 Serializable(我正在传递对象)