我有一个 ArrayList 文档,我想将此文件发送到另一个 Activity。但是如何在 SecondActivity 中获取这个值
我尝试的是 在第一个 Activity 中
private ArrayList<File> documents;
Intent selectLabInt = new Intent(FirstActivity.this, SecondActivity.class);
selectLabInt.putExtra("patient_name", patientNameStr);
selectLabInt.putExtra("referal_notes", referalNotesStr);
selectLabInt.putExtra("fileList",documents);
startActivity(selectLabInt);
最佳答案
如果您的File
是可序列化的,那么您可以像这样传递ArrayList
:
在发送 Activity 中:
ArrayList<File> documents= new ArrayList<File>();
intent.putExtra("documents", documents);
在接收 Activity 中:
ArrayList<File> documents = (ArrayList<File>)getIntent().getSerializableExtra("documents");
关于android - 如何使用 Intent 将 ArrayList<File> 对象从一个 Activity 传递到另一个 Activity?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35789288/