The TextView
is in layout fragment_main
but you've only inflated activity_main
with setContentView()
. The view you're trying to find is not in the activity view hierarchy.
Possible solutions:
Move the
TextView
to your activity layout.Move the code accessing the
TextView
to the fragment'sonCreateView()
.