我正在尝试在Android开发中的片段之间传递arraylist.这是我尝试将事务数组列表传递给另一个片段的部分:
switch (menuItem.getItemId()){
case R.id.expenses:
final ExpenseActivity expenseFragment = new ExpenseActivity();
new GetAllTransactionAsyncTask(
new GetAllTransactionAsyncTask.OnRoutineFinished() {
public void onFinish() {
FragmentTransaction expsenseTransaction = getSupportFragmentManager().beginTransaction();
Bundle bundle = new Bundle();
//bundle.putParcelableArrayList("transactionlist", GetAllTransactionAsyncTask.allTransaction);
//bundle.putString("transactionlist", GetAllTransactionAsyncTask.allTransaction);
expenseFragment.setArguments(bundle);
expsenseTransaction.replace(R.id.frame,expenseFragment);
expsenseTransaction.commit();
}
}).execute(session_accountID);
return true;
}
GetAllTransactionAsyncTask.allTransaction将返回一个事务数组列表.至于我的交易实体类,我实现了Serializable:
import java.io.Serializable;
@SuppressWarnings("serial")
public class Transaction implements Serializable{
...
}
我不确定如何实际在片段之间传递对象数组列表.我注释掉这两行,因为它们是不兼容的类型.
有任何想法吗?提前致谢.