Reputation: 29
I know there is some questions like this around, but they don't seem to work because they completely remove the view and that's not I want.
I have this design, a dual pane where I have a fragment and a Fragment Layout. Where the details on the right are shown. See image:
The problem is when I switch tabs and come back to Measurement tab, the fragment on the right doesn't clean it self. See image:
The information on the right is added programmatically on run time, some LinearLayout for the Header, another LinearLayout for the details and another LinearLayout for the buttons that are at the end when you scroll the details on the right.
I tried using:
ViewGroup vg = (ViewGroup) FindViewById(Resource.Id.data_memory_details).Parent;
vg.RemoveView(FindViewById(Resource.Id.data_memory_details));
and:
ViewGroup vg = (ViewGroup) FindViewById(Resource.Id.data_memory_details).Parent;
vg.RemoveAllViews()
But this doesn't work because it completely removes the right side, the next time it loads the left pane is filling the whole width of the screen.
Another small question would be, where is the correct place to clean the contents? Should I do it OnPause()? When I change tabs and the Measurement Activity goes to the OnPause could I clean there?
Upvotes: 2
Views: 3272
Reputation: 21
If you want to clear data from the fragment, Go to the activity that contains that fragments and use
getIntent().setFlags(Intent.FLAG_ACTIVITY_CLEAR_STACK);
Upvotes: 0
Reputation: 4698
do your login in -
@Override
public void onDetach() {
super.onDetach();
//write your logic here
}
Upvotes: 1