On Add Previous Element Getting Replaced In Arraylist
did debugging. I can clearly see after entryLogs.add(dl); in the value of entryLogs. the first data is replaced and a second has been inserted to the ArrayList. what is happening i
Solution 1:
In the class DiaryLogs.java
you declare the strings timeEntry and entryEntered as static
staticString timeEntry;
staticString entryEntered;
Remove the static modifier and you'll be fine. Static objects will have the same value for any instance of that class (and are accessible even without having an instance of it), so if you set the value in another object, every instance will use that value.
Solution 2:
Maybe you should remove the line 64
entryLogs = new ArrayList<DiaryLogs>();
and initialize the ArrayList on the line 22
ArrayList<DiaryLogs> entryLogs;
Maybe it helps :)
Solution 3:
Put these two lines
timeText = (EditText) getView().findViewById(R.id.dateTimeEText);
entryText = (EditText) getView().findViewById(R.id.diaryEntryEText);
in @Override public void onClick(View v) { }
May this will help.
Post a Comment for "On Add Previous Element Getting Replaced In Arraylist"