I am trying to pass arraylist between fragments in Android development. This is the part where I tried to pass Transaction array list to another fragment:
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;
}
The GetAllTransactionAsyncTask.allTransactionwill return a Transaction array list. As for my transaction entity class, I implemented Serializable:
import java.io.Serializable;
@SuppressWarnings("serial")
public class Transaction implements Serializable{
...
}
I not sure how do I actually pass an object array list between fragments. I commented out the two lines as they are incompatible type.
Any ideas? Thanks in advance.