Created
March 12, 2014 19:49
-
-
Save nseidm1/9514890 to your computer and use it in GitHub Desktop.
Get the parent fragment, of a child fragment, on 4.0+ devices using SDK fragments, not V4 Fragments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Fragment getParentFragmentTwo() { | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { | |
| return getParentFragment(); | |
| } else { | |
| View view = getView(); | |
| while (view.getParent() != null) { | |
| Fragment fragment = getFragmentManager().findFragmentByTag((String) view.getTag()); | |
| if (fragment != null) | |
| return fragment; | |
| view = (View) view.getParent(); | |
| } | |
| return null; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment