Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVE] You can use androidx.fragment.app.Fragment constructor and pass R.layout there instead of overriding onCreateView like we used to #4

Open
rcd27 opened this issue Jul 1, 2019 · 2 comments

Comments

@rcd27
Copy link

rcd27 commented Jul 1, 2019

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

@JeroenMols
Copy link
Owner

Thanks for the suggestion. I'm not aware of this (and can't find it myself), do you have a link to the fitting AndroidX docs?

@Gryzor
Copy link

Gryzor commented Oct 10, 2019

I do, It was added in 1.1.0 (as seen here: https://developer.android.com/jetpack/androidx/releases/fragment#version_110_3):

FragmentActivity LayoutId constructor: Subclasses of FragmentActivity can now optionally call into a constructor on FragmentActivity that takes an R.layout ID, indicating the layout that should be set as the content view as an alternative to calling setContentView() in onCreate(). This does not change the requirement that your subclass have a no-argument constructor.

Fragment LayoutId constructor: Subclasses of Fragment can now optionally call into a constructor on Fragment that takes an R.layout ID, indicating the layout that should be used for this fragment as an alternative to overriding onCreateView(). The inflated layout can be configured in onViewCreated().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants