android getMenuInflater() in a fragment subclass - cannot resolve method

后端 未结 4 820
萌比男神i
萌比男神i 2021-02-07 19:32

I am trying to inflate a menu in a class that inherits the Fragment class. Here is my OnCreateOptionsMenu() method -

@Override
public bo         


        
4条回答
  •  Happy的楠姐
    2021-02-07 20:20

    • According to API not overriding a super method.
    • You are not calling the correct method inflate.

    You must use it in this way:

    @Override
    public boolean OnCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.forecastfragment, menu);
        return true;
    }
    

提交回复
热议问题