bCliks
bCliks

Reputation: 2978

extends BaseAdapter results are overwrite previous ArrayList Items

i have a DateApapter class like this..

 public class DateAdapter extends BaseAdapter
    { 
    ...
    }

i call this DateApapter in 12 different places from my "mainActivity" by using constructor and store this result in a DateApapter object "mDefaultAdapter " like this..

mDefaultAdapter = new DateAdapter(this,days,sysDate,disablePastDays, selectedDateTypeDf);

and stored this various results of mDefaultAdapter in ArrayList like this..

ArrayList<DateAdapter> mDefaultAdapterList = new ArrayList<DateAdapter>();
mDefaultAdapterList.add(mDefaultAdapter);

now coming to the problem,

Why DateAdapter results are overwrite in previous ArrayList Items? I am not using any Static variables or methods in whole program. Please help me to fix this problem. Thanks..

Upvotes: 0

Views: 174

Answers (2)

bCliks
bCliks

Reputation: 2978

It was my mistake.. The problem is Illegal object reference overwrite my previous ArrayList Items. I saved myself by making a separate object for Date Adapter.

Upvotes: 0

Benito Bertoli
Benito Bertoli

Reputation: 25793

I'm not really sure what's happening with your adapter. Maybe you're using the same ArrayList object with all the adapters.

But I think you should reconsider your approach.

Here's what I would do.

1- Store the calendar events in an SQLite database.

2- In your FragmentPagerAdapter, pass the position to your Calendar Fragment.

3- In your Calendar Fragment, retrieve the position ( 0 : January - 11 : December) and query your database to retrieve the events.

Upvotes: 1

Related Questions