2015-10-18 55 views
0

//這是我路過一類的ArrayList到另一個活動在Android Studio中

private String name; 
private int height; 
private float weight; 
private int age; 
private Sex gender; 

public String getName() { 
    return name; 
} 

public int getHeight() { 
    return height; 
} 

public float getWeight() { 
    return weight; 
} 

public int getAge() { 
    return age; 
} 

public Sex getGender() { 
    return gender; 
} 

public enum Sex {male, female, others} 

; 

public User(String name, Sex gender, int age, float weight, int height) { 
    this.name = name; 
    this.gender = gender; 
    this.age = age; 
    this.weight = weight; 
    this.height = height; 
    } 
} 

這是第一次活動

ArrayList<User> userList = new ArrayList<User>(); 
Intent intent = new Intent(ProfileSelect.this,MainActivity.class); 
     intent.putExtra("list",userList); 
     startActivity(intent); 

,現在我想展示給用戶名單另一項稱爲主要活動的活動。我如何檢索主要活動中的列表? Tq的提前..

回答

0

可以使用EventBus

// Post Object 
EventBus.getDefault().postSticky(yourObject); 

// Get Object 
YourClass yourObject = EventBus.getDefault().getStickyEvent(YourClass.class); 
相關問題