I have one class Days
public class Days implements Serializable {
private String id;
private List<Hours> hours;
//getters and setters
}
And a class Hours
public class Hours implements Serializable{
private String id;
private String comments;
//getters and setters
}
I also have an activity with a ExpandableList that shows days as groups and hours as children. When I click on a specific hour, I pass the object hours to edit on another activity.
public class DaysListActivity extends ExpandableListActivity
implements OnChildClickListener
{
//Other methods
@Override
public boolean onChildClick(parameters...)
{
Intent i = new Intent(getApplicationContext(),HourActivity.class);
i.putExtra("hourClicked",day.getHour(idHourClicked));
startActivity(i);
}
}
In HourActivity.class
public class HourActivity extends Activity{
@Override
public void onCreate(Bundle savedInstance)
{
...
Intent i = getIntent();
Hour hour = (Hour) i.getSerializableExtra("hourClicked");
updateHour(hour);
....
}
public void updateHour(Hour hour)
{
hour.setComment("Hellow world");
Toast toast = Toast.makeText(getApplicationContext(), hour.getComment(), Toast.LENGHT_SHORT);
toast.show();
}
}
Everything goes fine, the toast shows me "Hello world". But when i came back to DayListActivity, the hour that i've clicked and updated keeps the same value, it doesn't refresh. Wrost, if I click on the same hour again, i'ts like it was never updated to "Hello world"
I've already tried notifyDataSetChanged() on adapter and invalidateViews() on ExpandableListView. Which step am I missing?