Reputation: 7947
I'm attempting to understand someone else's code. They are using fragments (which I'm rather hazy on).
I know that a fragment starts up with onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState
.. but I can't fathom where the "container" was set up.
where should I look?
Upvotes: 3
Views: 361
Reputation: 1639
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
v = inflater.inflate(R.layout.news_list, container, false);
return v;
}
The layout news_list
is for this fragment.
Upvotes: -1
Reputation: 86948
container
is handled by the Android framework, it typically refers to View passed by id in methods like FragmentTransaction's add(int containerViewId, Fragment fragment)
or replace(int containerViewId, Fragment fragment)
.
For example, this is from the Developer's Guide:
ExampleFragment fragment = new ExampleFragment();
fragmentTransaction.add(R.id.fragment_container, fragment);
fragmentTransaction.commit();
Upvotes: 4