2015-10-18 2 views
0

// это мой класспрохождение ArrayList класса в другую деятельность в андроиде студии

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; 
    } 
} 

это от 1-я активности

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

А теперь я хотел бы, чтобы отобразить список пользователей другое действие, называемое mainactivity. Как получить список в mainactivity? Тк заранее ..

ответ

0

вы можете использовать EventBus

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

// Get Object 
YourClass yourObject = EventBus.getDefault().getStickyEvent(YourClass.class); 
Смежные вопросы