我有一个SubAccount的arraylist,SubAccount就是这个类:
class SubAccount {
private String username;
private String uniqueKey;
private String accountPictureString;
public SubAccount() {
}
SubAccount(String username, String uniqueKey, String accountPictureString) {
this.username = username;
this.uniqueKey = uniqueKey;
this.accountPictureString = accountPictureString;
}
public void setAccountPictureString(String accountPictureString) {
this.accountPictureString = accountPictureString;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
String getAccountPictureToString() {
return accountPictureString;
}
String getUniqueKey() {
return uniqueKey;
}
public void setUniqueKey(String uniqueKey) {
this.uniqueKey = uniqueKey;
}
}
所以我需要做的是将这个arraylist从一个活动(LoginActivity)传递到另一个活动中的片段(ProfileViewFragment)(MainTabsActivity)
所以我找到了一种方法将数组从MainTabsActivity传递给片段,方法是将arraylist变量设为public并在onCreateView方法中使用这行代码:
ArrayList<SubAccount> subAccountsList = (ArrayList<SubAccount>) ((MainTabsActivity) getActivity()).subAccountsList;
所以现在我需要将arraylist从第一个活动(LoginActivity)传递给片段活动(MainTabsActivity)
谢谢你!