I am trying to add elements to a list
here is my parent class
public class TodoParent {
public String ParentTitle;
public Integer ParentId;
public List<ToDoModel> mChildList;
public long EpochTime;
public TodoParent(String mTitle,List<ToDoModel> childModels) {
this.ParentTitle = mTitle;
this.mChildList = childModels;
}
public TodoParent() {
}
public String getParentTitle() {
return ParentTitle;
}
public Integer getParentId() {
return ParentId;
}
public List<ToDoModel> getmChildList() {
return mChildList;
}
public void setParentTitle(String title) {
ParentTitle = title;
}
public void setParentId(Integer mId) {
ParentId = mId;
}
public void setmChildList(List<ToDoModel> list) {
mChildList = list;
}
}
Here is the situation where i need to add element
@Override
public void applyTexts(String header, String footer, String listType, String timeOfDay, int priotity,long mEpochtime) {
//Toast.makeText(this,(String) timeOfDay, Toast.LENGTH_SHORT).show();
ToDoModel toDoModel = new ToDoModel();
TodoParent todoParent = new TodoParent();
toDoModel.header = header;
toDoModel.footer = footer;
toDoModel.task = listType;
toDoModel.tod = timeOfDay;
toDoModel.priorityVal = priotity;
toDoModel.epochTime = mEpochtime;
toDoModel.id = toDoModelList.size() + 1;
todoParent.ParentTitle = footer;
todoParent.mChildList.add(toDoModel);
todoParent.EpochTime = mEpochtime;
Toast.makeText(getActivity(), "New List Item Added", Toast.LENGTH_SHORT).show();
//mAdapter.add(toDoModelList.size(), toDoModel);
parentAdapter.add(todoParentList.size(),todoParent);
//input.add("To Do New1");
}
todoParent.mChildList.add(toDoModel)
is not working. How can I add toDoModel
to mChildList
?
I am new to java and this is something i am working on as a training. So any help is appreciated.Thankyou