Ramakanth Reddy
Ramakanth Reddy

Reputation: 15

ArrayList with Multiple data

I have a small issue with ArrayList. I have to fetch the document from the server. The document contains 7 fields of data. I have to show the document names in the list view. For this I have added different fields data to the different ArrayList. So when I click on the document name, based on the position of the document, I fetched the all fields data from the different Arraylist based on the position.

But Have a small issue using by using the above procedure. Is there any procedure that is not depend on the position, what I want is irrespective of position if I click on the Document,based on the keyword document data to be extract.

Any Help Appreciated. Thanks in Advance.

Upvotes: 0

Views: 731

Answers (1)

Paresh Mayani
Paresh Mayani

Reputation: 128428

I got your point. If you try to manage different ArrayLists then it would be difficult to manage it. I mean if you delete item from particular position from particular ArrayList then you will have to delete items from same position from other ArrayList, if you forgot to do so then it will be unbalanced.

Solution:

Instead feasible solution is to create ArrayList<Object> or ArrayList<HashMap<String,String>>, so your every item is the type of particular object, and every object contains detail and everything of particular items.

For example: ArrayList<Documents>, here ArrayList will contains list of Documents objects, and every objects contains values of 7 fields.

Its simply easy to define Documents class with getter/setter attributes.

Upvotes: 2

Related Questions