Create a Model Class as follows:-
public class Model {
private String title;
private String desc;
private int background;
private int profile;
public Model(String title, String desc, int background, int profile) {
this.title = title;
this.desc = desc;
this.background = background;
this.profile = profile;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public int getBackground() {
return background;
}
public void setBackground(int background) {
this.background = background;
}
public int getProfile() {
return profile;
}
public void setProfile(int profile) {
this.profile = profile;
}
}
Then when you have to add items in Arraylist just create a model with appropriate items and add it as follows:-
ArrayList<Model> modelList = new ArrayList<>();
Model model1 = new Model("ahmad", "China", R.drawable.apple_ex, R.drawable.apple_ex);
Model model2 = new Model("ali", "India", R.mipmap.ic_launcher, R.drawable.apple_ex);
Model model3 = new Model("omar", "United States", R.mipmap.ic_launcher, R.drawable.apple_ex);
modelList.add(model1);
modelList.add(model2);
modelList.add(model3);
Now your modelList will have all the values that you want. Then you can use it to get values using forloop
for (Model model : modelList) {
model.getTitle();
model.getDesc();
model.getBackground();
model.getProfile();
}