简体   繁体   中英

Access to the parent activity of a fragment

I have an activity that extends SherlockFragmentActivity. Clicking on any button in this activity makes that frame replaced with a fragment. Fragment contains a ViewPager that a ListView is in it. OnListItemClick event is located within the fragment. when clicking on any of the items in the ListView it makes the new fragment open, and this continues to be hierarchical. To open the second and third fragment and etc, Activity does not have control to replace New Fragment.

My question is:

How can I when I'm in a Fragment, come back to parent activity of this fragment?

Thanks

Have you ever gone through the official documentation for using Fragments in Android ?

Please go through it atleast thrice I'd say cause it is the best place to start learning about fragments. In case you still don't want to do that, here's a sample project (which is also provided by the same site) to start with.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM