How to add HashMap to ArrayList
problem:
prodHashMap.put("prod", tvProd.getText().toString());
You are using the same key each time you are adding an element to the the arraylist with the same reference to the HashMap
thus changing its values.
Solution:
create a new instance of HashMap
each time you want to add it to the ArrayList
to avoid changing its values upon calling addProd
public void addProd(View ap)
{
// test arraylist of hashmaps
HashMap<String, String> prodHashMap = new HashMap<String, String>();
prodHashMap.put("prod", tvProd.getText().toString());
prodArrayList.add(prodHashMap);
tvProd.setText("");
// check data ///
Log.e("myLog","Data prodArrayList in ADD Method Size = "+prodArrayList.size());
for(int i=0; i< prodArrayList.size();i++)
{
Log.e("myLog","Data prodArrayList in ADD Method = "+prodArrayList.get(i).toString());
}
}