Pass ArrayList from fragment to another fragment(extends ListFragment) using bundle, seListAdapter runtime error

13,630

Solution 1

You can only pass custom object or ArrayList of custom object via Bundle(or Intent) when the object is either Parcelable or Serializable. One more thing if your fragments are in same activity then why you are passing array. you just create getter and setter for list in your Activity and access them like ((Activity)getActivity).getArraylist() in your listFragment. For creating object Parcelable do something like below.

import android.os.Parcel;
import android.os.Parcelable;

public class Address implements Parcelable {

private String name, address, city, state, phone, zip;

@Override
public int describeContents() {
    return 0;
}

/*
        THE ORDER YOU READ OBJECT FROM AND WRITE OBJECTS TO YOUR PARCEL MUST BE THE SAME
 */

@Override
public void writeToParcel(Parcel parcel, int i) {
    parcel.writeString(name);
    parcel.writeString(address);
    parcel.writeString(city);
    parcel.writeString(state);
    parcel.writeString(phone);
    parcel.writeString(zip);
}


public Address(Parcel p){
    name = p.readString();
    address = p.readString();
    city = p.readString();
    state = p.readString();
    phone = p.readString();
    zip = p.readString();
}

// THIS IS ALSO NECESSARY
public static final Creator<Address> CREATOR = new Creator<Address>() {
    @Override
    public Address createFromParcel(Parcel parcel) {
        return new Address(parcel);
    }

    @Override
    public Address[] newArray(int i) {
        return new Address[0];
    }
};
}

Solution 2

I have seen your code for your given link and thats why I am posting a new Ans. One thing if you read your code carefully, you have declared ArrayAdapter<String> in Monday_fragment, so this list initialize every time when you replace this fragment with other. So just create a ArrayAdapter<String> in MainActivity and getter, setter for the same and change your methode ArrayList<String> toStringList(Collection<DiaryLogs> entryLogs) in the Monday_fragment like below

public ArrayList<String> toStringList(Collection<DiaryLogs> entryLogs) {
    ArrayList<String> stringList =  ((MainActivity)getActivity()).getMyStringList();

    for (DiaryLogs myobj : entryLogs) {
        String objctString = myobj.toString();

        stringList.add(objctString);
    }
    ((MainActivity)getActivity()).setMyStringList(stringList); 
    return stringList;
}
Share:
13,630
t_godd
Author by

t_godd

Knock knock: Java &gt; C++

Updated on June 04, 2022

Comments

  • t_godd
    t_godd almost 2 years

    I have tried using Static variable for the ArrayList but in the ListFragment class, while debugging it's value is null.

    I think the ListFragment gets created before initialising the ArrayList, thats why it's null, but not sure.

    Suggest if i can use any other way to send the inflated ArrayList from Fragment class to other Fragment class which extends ListFragment.

    Thanks in advance.

    Objective (This is the clue, what needs to be done)

    In the Monday_fragment's onStart() method use the findByView() method to find the label for the save entry button in the pages view. Using the reference to the button attach a setOnClickListener() method to the save button. You will need to save the time and the diary entry strings contained in the EditText fields on the page in this method.

    Use findViewById() to also get a reference to the first EditText field and use this to get the text of the field as a string and save it to a string. Repeat this for the next EditText - the diary entry. You will need a publicly accessible variable to store a reference for the day (Monday..Friday), the date time string, and the diary entry string. Create a new class (diaryLogs) with these fields to hold the values and a single constructor that takes an int (0 Mon, 1 Tue, 2 Wed etc) and two strings for the date time and diary entry to initialise an instance of the object. As a number of entries will be made for the same day, use an ArrayList < diaryLogs > to store the values. As this value will be shared between fragments declare the variable as static in the MainActivity class. Use the .add() method of ArrayList to add the new diaryLog to the ArrayList in your setOnClickListener() method. Repeat this operation for the other diary page fragments.

    The monday_list fragment consists of a ListView and a button used to return to the Monday_fragment page. Create these objects in the monday_list xml file. Create a Monday_list_fragment that extends the ListFragment class. In the onCreateView() method inflate() the monday_list resource.

    In the onCreate() method you need to provide a single array of strings as the source for the list in the setListAdapter() method used to fill the ListView on the page. The strings are in your static ListArray variable in MainActivity. However, they are not in the form required and you must unpack the diaryLog elements to get to the required strings. To do this you must create a String array big enough to hold the strings to display. As this consistes of a date/time string followed by a diary entry string there will be two such strings for each diaryLog element. Use a Iterator to iterate through your ListArray. Copy the date string and diary string strings into your local string. Then use this local string as the relevant parameter of setListAdapter() so that the ListView displays the required strings.

    Add the click handler in the MainActivity java file so that a click on the Save Diary Entries button in the Monday fragment page causes the Monday_list_fragment to be made visible using the FragmentManager. Also add a click handler in MainActivity so that a click on the Return to Monday Diary button returns to the Monday_fragment page.

    UPDATE Class MainActivity

    public class MainActivity extends Activity {
    
    
        public static int Monday=0;
        /*public static int Tuesday=1;
        public static int Wednesday=2;
        public static int Thursday=3;
        public static int Friday=4;
        public static String timeEntry;
        public static String entryEntered;*/
       // public static ArrayList<String> logs;
        //public static String[] entry;
        //public static String time;
        //public static String text;
        //public static String totalEntry;
        //public static ArrayList<DiaryLogs> diaryLogs;
        //public static ArrayList<DiaryLogs> test;
        //public static DiaryLogs[] entryLogs;
        //public static ArrayAdapter<DiaryLogs> monAdapter;
        //public static ArrayList< String > myStringList;
      //public static ArrayList<DiaryLogs> entryLogs;
    
    
        public static ArrayList<String> myStringList;
    
        public static ArrayList<String> getMyStringList() {
            return myStringList;
        }
    
    
    
    
        public void setMyStringList(ArrayList<String> myStringList) {
            this.myStringList = myStringList;
        }
    
    
    
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Home_fragment hf = new Home_fragment();
            fragmentTransaction.replace(android.R.id.content, hf);
            fragmentTransaction.commit();
            setContentView(R.layout.activity_main);
    
    
    
            }
    
    
    
    
        public void monClick(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Monday_fragment mf = new Monday_fragment();
            fragmentTransaction.replace(android.R.id.content, mf);
            fragmentTransaction.commit();
        }
    
        public void tuesClick(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Tuesday_fragment tf = new Tuesday_fragment();
            fragmentTransaction.replace(android.R.id.content, tf);
            fragmentTransaction.commit();
        }
    
        public void wedClick(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Wednesday_fragment wf = new Wednesday_fragment();
            fragmentTransaction.replace(android.R.id.content, wf);
            fragmentTransaction.commit();
        }
    
        public void thursClick(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Thursday_fragment thf = new Thursday_fragment();
            fragmentTransaction.replace(android.R.id.content, thf);
            fragmentTransaction.commit();
        }
    
        public void friClick(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Friday_fragment ff = new Friday_fragment();
            fragmentTransaction.replace(android.R.id.content, ff);
            fragmentTransaction.commit();
        }
    
        public void next_Home_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Monday_fragment mf = new Monday_fragment();
            fragmentTransaction.replace(android.R.id.content, mf);
            fragmentTransaction.commit();
        }
    
        public void previous_Home_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Friday_fragment ff = new Friday_fragment();
            fragmentTransaction.replace(android.R.id.content, ff);
            fragmentTransaction.commit();
        }
    
        public void next_Mon_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Tuesday_fragment tf = new Tuesday_fragment();
            fragmentTransaction.replace(android.R.id.content, tf);
            fragmentTransaction.commit();
        }
    
        public void previous_Mon_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Friday_fragment ff = new Friday_fragment();
            fragmentTransaction.replace(android.R.id.content, ff);
            fragmentTransaction.commit();
    
        }
    
        public void next_Tues_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Wednesday_fragment wf = new Wednesday_fragment();
            fragmentTransaction.replace(android.R.id.content, wf);
            fragmentTransaction.commit();
        }
    
        public void previous_Tues_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Monday_fragment mf = new Monday_fragment();
            fragmentTransaction.replace(android.R.id.content, mf);
            fragmentTransaction.commit();
    
        }
    
        public void next_Wed_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Thursday_fragment thf = new Thursday_fragment();
            fragmentTransaction.replace(android.R.id.content, thf);
            fragmentTransaction.commit();
        }
    
        public void previous_Wed_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Tuesday_fragment tf = new Tuesday_fragment();
            fragmentTransaction.replace(android.R.id.content, tf);
            fragmentTransaction.commit();
    
        }
    
        public void next_Thurs_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Friday_fragment ff = new Friday_fragment();
            fragmentTransaction.replace(android.R.id.content, ff);
            fragmentTransaction.commit();
        }
    
        public void previous_Thurs_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Wednesday_fragment wf = new Wednesday_fragment();
            fragmentTransaction.replace(android.R.id.content, wf);
            fragmentTransaction.commit();
    
        }
    
        public void next_Fri_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Monday_fragment ff = new Monday_fragment();
            fragmentTransaction.replace(android.R.id.content, ff);
            fragmentTransaction.commit();
        }
    
        public void previous_Fri_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Thursday_fragment wf = new Thursday_fragment();
            fragmentTransaction.replace(android.R.id.content, wf);
            fragmentTransaction.commit();
    
        }
    
        public void home_Click(View view) {
            FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            Home_fragment hf = new Home_fragment();
            fragmentTransaction.replace(android.R.id.content, hf);
            fragmentTransaction.commit();
    
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
    
        }
    
        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            // TODO Auto-generated method stub
            switch (item.getItemId()) {
            case R.id.action_profile:
                FragmentManager fragmentManager = getFragmentManager();
                FragmentTransaction fragmentTransaction = fragmentManager
                        .beginTransaction();
                Profile_fragment pf = new Profile_fragment();
                fragmentTransaction.replace(android.R.id.content, pf);
                fragmentTransaction.commit();
    
                break;
            case R.id.action_saveEntries:
    
                break;
            case R.id.action_sendAllEntries:
                //call delete dialog
                deleteDialog();
                break;
            }
            return false;
        }
    
        @Override
        public void onBackPressed() {
            new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher)
                    .setTitle("Save entries to DB first?")
                    .setNegativeButton("No", new OnClickListener() {
    
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                            // if no, close app
                            MainActivity.this.finish();
    
                        }
                    })
                    .setPositiveButton(android.R.string.ok, new OnClickListener() {
    
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                            // if ok, save entries to Database
    
                        }
                    })
    
                    .create().show();
    
        }
    
        public void deleteDialog() {
    
            new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher)
                    .setTitle("Are you sure? This will delete all entries.")
                    .setNegativeButton(android.R.string.cancel, new OnClickListener() {
    
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
    
    
                        }
                    })
                    .setPositiveButton(android.R.string.ok, new OnClickListener() {
    
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
    
    
                        }
                    })
    
                    .create().show();
    
        }
    
    }
    

    Custom Object Class DiaryLogs

    public class DiaryLogs {
    
        //public static ArrayList<DiaryLogs> entryLogs;
    
        String timeEntry, entryEntered;
        int day;
    
        // single constructor that takes an integer and two string
        public DiaryLogs(int day, String timeEntry, String entryEntered) {
            super();
            this.day = day;
            this.timeEntry = timeEntry;
            this.entryEntered = entryEntered;
    
        }
    
        public String getTimeEntry() {
            return timeEntry;
        }
    
        public void setTimeEntry(String timeEntry) {
            this.timeEntry = timeEntry;
        }
    
        public String getEntryEntered() {
            return entryEntered;
        }
    
        public void setEntryEntered(String entryEntered) {
            this.entryEntered = entryEntered;
        }
    
        public int getDay() {
            return day;
        }
    
        public void setDay(int day) {
            this.day = day;
        }
    
        @Override
        public String toString() {
            // TODO Auto-generated method stub
            return this.timeEntry + "\n" + this.entryEntered;
    
    
        }
    
    
    }
    

    UPDATE Class Monday_fragment

    public class Monday_fragment extends Fragment {
    
        //public ArrayList<String> myStringList;
        Bundle bundle;
        ArrayList<DiaryLogs> entryLogs;
        EditText timeText;
        EditText entryText;
        DiaryLogs dl;
        String timeEntry;
        String entryEntered;
        ArrayList<String> myStringList;
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
    
            return inflater.inflate(R.layout.monday_fragment, container, false);
    
        }
    
        @Override
        public void onViewCreated(View view, Bundle savedInstanceState) {
            currentDateTime();
            super.onViewCreated(view, savedInstanceState);
    
        }
    
        public void currentDateTime() {
            EditText timeText = (EditText) getView().findViewById(
                    R.id.dateTimeEText);
            SimpleDateFormat df = new SimpleDateFormat("d/M/yyyy:H:m");
            String dateTime = df.format(Calendar.getInstance().getTime());
            timeText.setText(dateTime);
        }
    
        /*public ArrayList<String> toStringList(Collection<DiaryLogs> entryLogs) {
            ArrayList<String> stringList = new ArrayList<String>();
    
            for (DiaryLogs myobj : entryLogs) {
                stringList.add(myobj.toString());
            }
    
            return stringList;
        }*/
        public ArrayList<String> toStringList(Collection<DiaryLogs> entryLogs) {
            ArrayList<String> stringList =  MainActivity.getMyStringList();
    
            for (DiaryLogs myobj : entryLogs) {
                String objctString = myobj.toString();
    
                stringList.add(objctString);
            }
            ((MainActivity)getActivity()).setMyStringList(stringList); 
            return stringList;
        }
    
        @Override
        public void onStart() {
            entryLogs = new ArrayList<DiaryLogs>();
    
            timeText = (EditText) getView().findViewById(R.id.dateTimeEText);
    
            entryText = (EditText) getView().findViewById(R.id.diaryEntryEText);
    
            Button saveBtn = (Button) getView()
                    .findViewById(R.id.saveDiaryEntryBtn);
            saveBtn.setOnClickListener(new View.OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
    
                    timeEntry = timeText.getText().toString();
    
                    entryEntered = entryText.getText().toString();
    
                    dl = new DiaryLogs(1, timeEntry, entryEntered);
    
                    entryLogs.add(dl);
    
                    //convert entryLogs to string array list
                    //myStringList = toStringList(entryLogs);
                    myStringList= MainActivity.getMyStringList();
                    myStringList = toStringList(entryLogs);
                    //myStringList.addAll(toStringList(entryLogs));
    
                    Toast.makeText(getActivity(), "Entry added \n" + dl,
                            Toast.LENGTH_SHORT).show();
                            entryText.setText("");
    
    
    
    
    
    
                }
    
            }
    
            );
            System.out.println(entryLogs);
    
            Button showBtn = (Button) getView().findViewById(
                    R.id.showDiaryEntriesBtn);
            showBtn.setOnClickListener(new View.OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
    
                    if (myStringList != null) {
                        bundle = new Bundle();
                        FragmentManager fragmentManager = getFragmentManager();
                        FragmentTransaction fragmentTransaction = fragmentManager
                                .beginTransaction();
                        Monday_list_fragment mlf = new Monday_list_fragment();
    
                        bundle.putStringArrayList("list", myStringList);
                        mlf.setArguments(bundle);
    
                        fragmentTransaction.replace(android.R.id.content, mlf);
                        fragmentTransaction.commit();
                    }
                    if (myStringList == null) {
                        Toast.makeText(getActivity(),
                                "No entry have been added yet", Toast.LENGTH_SHORT)
                                .show();
                    }
                }
            });
    
            super.onStart();
        }
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
        }
    
    }
    

    Class Monday_list_fragment

        public class Monday_list_fragment extends ListFragment {
        ArrayList<String> test;
        Bundle bundle;
    
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
    
            super.onCreate(savedInstanceState);
            bundle = getArguments();
            System.out.println(bundle);
           //test = bundle.getStringArrayList("list");
    
        }
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            // TODO Auto-generated method stub
    
            return inflater
                    .inflate(R.layout.monday_list_fragment, container, false);
    
        }
    
        @Override
        public void onViewCreated(View view, Bundle savedInstanceState) {
    
            super.onViewCreated(view, savedInstanceState);
    
           /* ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
                    android.R.layout.simple_list_item_1, test);
            // once adapter set throws runtime error
            setListAdapter(adapter);*/
    
        }
    
    
    
    }
    
  • t_godd
    t_godd about 10 years
    Thanks bro. I tried getting the array from getter but when setting the setListAdapter it's throwing runtime exception. I have edited the Question and added the codes, check UPDATE.
  • maddy d
    maddy d about 10 years
    buddy I have told you, create getter and setter in Activity not in fragment, because when you replace Fragment then the list will not exist anymore. Now I can see that the arraylist is a string arraylist so you can send it via Arguments between fragments. use bundle.putStringArrayList("list", "myStringList"). ask me if you need more details
  • t_godd
    t_godd about 10 years
    i have tried via arguments, but i get runtime exception once I 'setListAdapter(adapter);'. But i can see the bundle was received in debug mode, as-well as ArrayList test contains entered values that came from the bundle arguments. I have updated the all the codes and the LogCat errors. If you can have a look please. Thanks for all your help.
  • maddy d
    maddy d about 10 years
    check two points. one your ListView has id "@id/android:list" ,second in onViewCreated check the object test in not null.
  • t_godd
    t_godd about 10 years
    my ListView id is all right. And yes test is null in onViewCreated, where as if I try to get test in onCreate just after getArgument. It throws runtime error. I think because initially its null. I tried printing bundle and it did have the value. I also updated the code.
  • t_godd
    t_godd about 10 years
    And you can also see all the code here github.com/tirthoguha/DroidProject
  • t_godd
    t_godd about 10 years
    It got fixed. @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); bundle = this.getArguments(); if (bundle != null){ test = bundle.getStringArrayList("list"); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, test); setListAdapter(adapter); } }
  • t_godd
    t_godd about 10 years
    The only problem Im having right now is that every time I add an entry, all entries should get stored in the ArrayList<DiaryLogs> entryLogs. But now then list is getting populated with only the last entry. Current code for adding value to ArrayList: ArrayList<DiaryLogs> entryLogs = new ArrayList<DiaryLogs>(); DiaryLogs dl = new DiaryLogs(1, timeEntry, entryEntered); entryLogs.add(dl);
  • t_godd
    t_godd about 10 years
    declared ArrayAdapter<String> in Monday_list_fragment, not in Monday_fragment. and I just realised i was creating entryLogs = new ArrayList<DiaryLogs>(); in OnClick, so i guess with new click the old was getting replaced rather than adding to the existing
  • maddy d
    maddy d about 10 years
    I am talking about the ArrayAdapter<String> which you are passing as Arguments from ` Monday_fragment` and yes your realization is correct.
  • t_godd
    t_godd about 10 years
    you mean 'ArrayList<String> myStringList' which is been used to send over bundle to the next fragment. Tell me if i'm wrong. So I declare that in Main activity and generate getters setter. Then change toStringList according to your in Monday_fragment?
  • maddy d
    maddy d about 10 years
    see the logic is the list which you want to show in Monday_list_fragment has to be declared in your MainActivity so that you can access it in both of your fragment, because you are adding data from Monday_fragment and showing list in Monday_list_fragment, so list should be global.
  • t_godd
    t_godd about 10 years
    check the updated code here, didnot commit. Updated MainActivity and Monday_fragment. now i get error in OnClick. I don't know if did everything correctly as you mentioned.
  • maddy d
    maddy d about 10 years
    you have not initialize myStringList in the MainAcitivity. initialize it in onCreate.
  • t_godd
    t_godd about 10 years
    buddy check the code in the repository, if possible. github.com/tirthoguha/DroidProject/blob/myDiary/src/com/exam‌​ple/… I kept it like before, without your new changes. And initialised the ArrayList DiaryLogs before onClick. i debugged it, what is happening is every time i enter new value it adds it in the arraylist but replaces the the first entry to be same as the second entry. for example: I add a and onclick it add a. again, add b and onclick it add b. but in the Arralist [17/4/2014:20:29 b, 17/4/2014:20:29 b] Suggest what can be done.
  • t_godd
    t_godd about 10 years
    i fixed it, Thanks for all your help. the variable timeEntry & entryEntered were declared static in class DiaryLogs. that's why all the trouble. But came into a new problem in first onClick it add the data to ArrayList. second onlcik to get List, first converts the custom ArrayList to String ArrayList, then puts it in bundle and replace fragment to show list. But even if i don't add new data, i wan't to show all the existing in custom ArrayList. How do I do that. Codes here: github.com/tirthoguha/DroidProject/tree/myDiary/src/com/exam‌​ple/…
  • t_godd
    t_godd about 10 years
    bro, all this stuff's working except this new thing. If you can help please. stackoverflow.com/questions/23160112/…