I have a Fragment in wich I have a listview. When I press on the listview position I open fragment dialog in which I send the position of clicked item. There I then can change some data live from the listview. But when I change my orientation (both the fragment and dialog fragment get different layouts), the live changes dont work anymore. If I go to another fragment and than back the change is made but not live.
both have setRetainInstance to true.
setting the adapter in the fragment:
documentPosListViewAdapter = new DocumentPosListViewAdapter(rootView.getContext());
listViewDocumentPos.setAdapter(documentPosListViewAdapter);
dialog listener:
@Override
public void onDataUpdated() {
currentWorkDocumentPos.calcPos();
session.getWorkDocumentPosDao().update(currentWorkDocumentPos);
currentWorkDocument.headCalc();
session.getWorkDocumentDao().update(currentWorkDocument);
refreshWorkDocumentLabels();
documentPosListViewAdapter.notifyDataSetChanged();
}
And what I am doing in the dialog:
currentWorkDocumentPos.setQuantity(quantity + 1);
String n_q = Double.toString(currentWorkDocumentPos.getQuantity());
editTextQuantity.setText(n_q);
editTextQuantity.setSelection(n_q.length());
myListener.onDataUpdated();
Everything works until I change screen orientation. Then live changes dont happen anymore. I am guessing that documentPosListViewAdapter.notifyDataSetChanged(); doesent do its work anymore but I am not sure why.
EDIT:
In the dialog i have these 2 parts and the dialog layout recreates itself on rotation normaly:
setRetainInstance(true); and
@Override
public void onDestroyView() {
if (getDialog() != null && getRetainInstance())
getDialog().setDismissMessage(null);
super.onDestroyView();
}
And in the mainFragment I have setRetainInstance(true); aswell and it recreates when I rotate my screen. If I remove setRetainInstance from main fragment then 2 things happen: 1. When I open another fragment and rotate layouts of both fragment seem to overlap istelf :S 2. When I open the fragment dialog from the listview and rotate the dialog looses the listview position on wich i clicked