我一直在尝试使用 actionbarsherlock 为菜单充气,但没有运气。请提出什么问题。这是我的代码:
@Override
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
MenuInflater inflater=getSherlockActivity().getSupportMenuInflater(); //getSherlockActivity() not recognised
inflater.inflate(R.menu.widgets_menu, menu);
// I have also tried this:
//MenuInflater inflater=getSupportMenuInflater();// getSupportMenuInflater() not recognized
//inflater.inflate(R.menu.widgets_menu, menu);
return true;
}
注意:我已经导入了所有必要的类
import com.actionbarsherlock.ActionBarSherlock;
import com.actionbarsherlock.ActionBarSherlock.OnCreateOptionsMenuListener;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
提前致谢。