0

Well, like the title says I want to populate a ListView with the data that is in multiple arrays. The ListItem structure looks like:

*Person Name

*01234567

*Boulevard of Broken Dreams, NY


and all the data for person name, phone number and adress is in seperate arraylists. So, I have arraylists personsArr, phonesArr, adressArr and I want to display that data in the ListView for each person that have a phone number and adress.

1 Answer 1

1

Use single class that have String persons, phones, address...

See NewsBean.java

public class Items {

private String name;
private int phoneNo;
private String address;

}

-Create getters and Setters Methods for name,phoneNo,address

Now add data in list

List<Items> list = new ArrayList<Items>();

 Items objItems = new Items();
 objItems.setName("Name"); 
 objItems.setPhoneNo(12345);
 objItems.setaddress("adress");

 list.add(objItems);  

Now get data from list

Items objItems =(Items)list.get(index);
String name = objItems.getName(); 
int phoneNo=objItems.getPhoneNo();
String address=objItems.getaddress();
Sign up to request clarification or add additional context in comments.

1 Comment

Thanke you for your answer, Samir. Now I have better application structure with Person class, but I still need to display Person's data in ListView. This is a similiar layout of ListView row: link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.