Reputation: 1721
I have ListFragment and getSupportMenuInflater() method is not recognized.
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
getSupportMenuInflater().inflate(R.menu.welcome, menu);
return true;
}
what do i need to define?
Upvotes: 4
Views: 4950
Reputation: 343
If you are on a Fragment, you should get the Activity and apply getMenuInflater()
to it.
@Override
public void onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getActivity().getMenuInflater().inflate(R.menu.welcome, menu);
}
Upvotes: 2
Reputation: 2104
You should use:
public boolean onCreateOptionsMenu(Menu menu) {
getActivity().getSupportFragmentManager().inflate(R.menu.welcome, menu);
return true;
}
Upvotes: 0
Reputation: 2719
You need to use
getSherlockActivity().getSupportMenuInflater().inflate(R.menu.welcome, menu);
Looks like getSherlockActivity
is just a shortcut to:
(SherlockActivity) getActivity()
Upvotes: 0