从Fragment Toolbar中删除optionMenu

时间:2017-08-07 05:46:05

标签: android android-fragments android-optionsmenu

optionMenu MainActivity onCreateOptionsMenu MainActivity MainActivity Toolbars OptionMenu ToolbarsOptionMenu [[UIScreen mainScreen] setBrightness:brightness]; volumeView = [[MPVolumeView alloc] initWithFrame: CGRectZero]; [self.view addSubview:volumeView]; for (id view in volumeView.subviews) { if([view isKindOfClass:[UISlider class]]) { volumeSlider = (UISlider*)view; NSLog(@"volumeSlider %f",volumeSlider.value); } } <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> <style> @font-face { font-family: myFirstFont; src: url(/fonts/sansation_light.woff); } #cont { font-family: myFirstFont; } </style> </head> <body> <div>hello world</div> <br /> <div id="cont">hello world</div> </body> </html> 他们自己的<system.webServer> <staticContent> <remove fileExtension=".woff" /> <mimeMap fileExtension=".woff" mimeType="application/font-woff" /> <remove fileExtension=".woff2" /> <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" /> </staticContent> </system.webServer> 。但问题是src在片段内的if上也可见。我不希望片段具有片段工具栏的let image = startingImageView.image let w = image.size.width let h = image.size.height print("image width: ", w) print("image height: ", h) var height = 0 if (w > h) { //landscape height = (self.startingFrame!.height / self.startingFrame!.width) * keyWindow.frame.width } else { //portrait height = (self.startingFrame!.height / self.startingFrame!.width) * keyWindow.frame.height }

2 个答案:

答案 0 :(得分:1)

您的片段setHasOptionsMenu(true)

中的

onCreate(); onCreateOptionsMenu中的

对您的片段菜单进行了充气,​​并使用MainActivity中的menu.removeItem(R.id.menu_id_to_be_removed);删除onPrepareOptionsMenu

答案 1 :(得分:0)

  

对于您不希望onCreateOptionsMenu的片段,在这些片段中包含以下代码

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setHasOptionsMenu(false);
}