0

I have these arrays:

ImageView aImages[], TextView aTextViewName[], Button aBuy[]

All arrays have same count of elements.

I want to create something like ListView that will take aImages[n], aTextViewName[n] and aBuy[n] from array and put it in a list like one element. Also it must create button listener for each button from list element.

I mean that first element in the list gets programly, and after I click on button - the are second element added to list. When I clicked on button of second element - the are third element added to list. And so on.

So there are three questions: 1) How make image, text, and button like single element but with access to each element (if I want to change text, but leave image, and button)? 2) How make dynamical adding these elements to list? 3) What can I use to store this elements?

)

1
  • Questions 1 and 2 solved. Thanks to user2905379 Commented Jan 5, 2016 at 2:26

1 Answer 1

1

1) you can use arraylist of object. for example:

public class Test{
   ImageView aImages;
   TextView aTextViewName;
   Button aBuy
}

then in your activity you can create and arraylist of test object.

ArrayList testList = new ArrayList<Test>();

2) when user click on add button store those detail to the testList and call notifyDataSetChanged() to update the listview.

yourAdapter.notifyDataSetChanged();

3) you may try to use sqlite if you are looking to store the data permanently

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you! Did you have any ideas about question (3) ? :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.