Harinarayanan v.m
Harinarayanan v.m

Reputation: 45

Fragment Lifecycle - onCreateView-UI elements

How we can access UI elements of a fragment in oncreateview, as onCreateView is called before onActivity created?enter image description here

Upvotes: 0

Views: 44

Answers (1)

Ryan M
Ryan M

Reputation: 20147

You should be inflating your UI elements within onCreateView, so they should be accessible there. As long as you're only accessing UI elements within your Fragment, it's safe to inflate and use them at that point - you don't need to wait for onActivityCreated or anything like that.

Upvotes: 1

Related Questions