-
Notifications
You must be signed in to change notification settings - Fork 2.3k
@FragmentByXXX inject child Fragments #1452
@FragmentByXXX inject child Fragments #1452
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MyFragment extends Fragment? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. :)
9d191fc to
02e8d75
Compare
|
@wintersandroid @mgod can you check if this is working for you? |
|
@WonderCsabo this fixes it for me. It's a bit of a pain as I expect I'll still be supporting APIs 15 and 16 for a while yet, but I can't tell if making this use the regular fragmentManager on API < 17 is useful. |
|
Sorry I do not really think understand what do you mean. We only support child Fragments from API 17, since that is when the method become avaialbe. And of course you can use the support lib. |
|
I can't use Ideally (for me), it would use the getFragmentManager() method when using API < 17 instead of failing to compile. It seems like this would be fairly safe as if I'm using the childFragmentManager in the code as well, it should give me appropriate warnings that I need to handle that separately in API < 17. |
|
So if the device is below API 17, the following <LinearLayout >
<fragment
android:id="@+id/myChildFragment"
android:name="com.foo.views.ChildMyFragment_" />
</LinearLayout>will add if (Build.SDK.VERSION_INT < 17) {
myChildFragment = getFragmentManager().findFragmentById(R.id.myChildFragment);
} else {
myChildFragment = getChildFragmentManager().findFragmentById(R.id.myChildFragment);
}This is a fairly reasonable request. |
|
So it took me about 10 minutes to get this working with API 15 and support "The 'childFragmentManager' parameter only can be used if the getChildFragmentManager() method is available in Fragment (from API 17). If you want to support older API versions, you should use android.support.v4.app.Fragment" |
|
Great! I will update the error message, then. |
02e8d75 to
6d5ad41
Compare
|
PR updated. |
6d5ad41 to
3e1be4d
Compare
3e1be4d to
9d65cfc
Compare
4bebefe to
966520b
Compare
9d65cfc to
8602ecf
Compare
|
It's okay. Rebase and you can merge this PR. |
8602ecf to
6f7ddbb
Compare
@FragmentByXXX inject child Fragments
|
Wiki edited. |
|
It turned out it may be not a good idea...
|
|
Huh. I've been using nested fragments in XML layouts for a while now. It looks like apparently the |
|
@mgod I faced the problem when the parent Fragment is recreated, I got duplicate ID error. http://stackoverflow.com/a/19815266/747412 |
Implements #1302.
This is a breaking change, because
@EFragments now always usegetFragmentManager()instead ofgetActivity().getFragmentManager()(orgetChildFragmentManager()but only if that is set).