No View Found For Id For ShooksFragment
I'm new to all this fragments stuff, and I get an error that couldn't be solved by any of the StackOverflow's questions. My problem is that I'm getting the error of No view found
Solution 1:
This line:
transaction.add(R.id.shooksLayout, fragment);
is incorrect because R.id.shooksLayout
is defined in the layout of your fragment
. The id
you specify in add()
should be the id
of a ViewGroup
you specify in your setContentView()
fot the activity. For example, for my fragments I usually keep an empty <FrameLayout>
in my activity and then provide the id
of this container in both fragment add()
and replace()
calls.
Solution 2:
try this:
ShooksFragment fragment = ShooksFragment.newInstance();
transaction.add(R.id.shooksLayout, fragment);
transaction.commit();
Post a Comment for "No View Found For Id For ShooksFragment"