0

I am developing an android application, in that I have a listview. Clicking on the list view item starts a new activity.

When I am going back to the parent activity (where the list view is) from the action bar back button on the child activity, it clears the list view of parent activity. But when I am using the android back button it goes back to parent activity but it does not clear the search result (list view).

How can I handle this in action bar back button ?

Example:

ActionBar back button-

1.

ParentActivity                 Child Activity

ListView
   Item1 -- Click an  item- -> Details about item1
   Item2
   Item3
   Item4

2.

Child Activity                              Parent Activity

Details about item1  -- Click back button   (The list is gone)
                        on action bar -->    
.
.
.
.

Android back button -

1.

ParentActivity                 Child Activity

ListView
   Item1 -- Click an  item- -> Details about item1
   Item2
   Item3
   Item4

2.

Child Activity                              Parent Activity

                                             (List is still here)
Details about item1  -- Click android back   ListView
                               button -->       Item1
                                                Item2
                                                Item3 
                                                Item4

Is there any setting or something I need to do to retain the state of parent activity when coming back from child activity ?

Rohit
  • 1,520
  • 2
  • 17
  • 36

1 Answers1

0

I guess when you press ActionBar back button,it destroys and recreates the parent activity.I did not use ActionBar,but it seems your problem is like to ActionBar 'up' button destroys parent activity, 'back' does not.So you can see that question's accepted Answer.There Aashir says:

You can override what the actionbar up button

Community
  • 1
  • 1
hasanghaforian
  • 13,858
  • 11
  • 76
  • 167