{"record":{"id":"ba36157311b759bb","repo":"jfeinstein10/SlidingMenu","slug":"slidestyle-must-be-either-sliding-window-or-slidin","errorCode":null,"errorMessage":"slideStyle must be either SLIDING_WINDOW or SLIDING_CONTENT","messagePattern":"slideStyle must be either SLIDING_WINDOW or SLIDING_CONTENT","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java","lineNumber":304,"sourceCode":"\t * Attaches the SlidingMenu to an entire Activity\n\t * \n\t * @param activity the Activity\n\t * @param slideStyle either SLIDING_CONTENT or SLIDING_WINDOW\n\t */\n\tpublic void attachToActivity(Activity activity, int slideStyle) {\n\t\tattachToActivity(activity, slideStyle, false);\n\t}\n\n\t/**\n\t * Attaches the SlidingMenu to an entire Activity\n\t * \n\t * @param activity the Activity\n\t * @param slideStyle either SLIDING_CONTENT or SLIDING_WINDOW\n\t * @param actionbarOverlay whether or not the ActionBar is overlaid\n\t */\n\tpublic void attachToActivity(Activity activity, int slideStyle, boolean actionbarOverlay) {\n\t\tif (slideStyle != SLIDING_WINDOW && slideStyle != SLIDING_CONTENT)\n\t\t\tthrow new IllegalArgumentException(\"slideStyle must be either SLIDING_WINDOW or SLIDING_CONTENT\");\n\n\t\tif (getParent() != null)\n\t\t\tthrow new IllegalStateException(\"This SlidingMenu appears to already be attached\");\n\n\t\t// get the window background\n\t\tTypedArray a = activity.getTheme().obtainStyledAttributes(new int[] {android.R.attr.windowBackground});\n\t\tint background = a.getResourceId(0, 0);\n\t\ta.recycle();\n\n\t\tswitch (slideStyle) {\n\t\tcase SLIDING_WINDOW:\n\t\t\tmActionbarOverlay = false;\n\t\t\tViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();\n\t\t\tViewGroup decorChild = (ViewGroup) decor.getChildAt(0);\n\t\t\t// save ActionBar themes that have transparent assets\n\t\t\tdecorChild.setBackgroundResource(background);\n\t\t\tdecor.removeView(decorChild);\n\t\t\tdecor.addView(this);","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/jfeinstein10/SlidingMenu/blob/4254feca3ece9397cd501921ee733f19ea0fdad8/library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java#L286-L322","documentation":"attachToActivity() only accepts the constants SlidingMenu.SLIDING_WINDOW or SlidingMenu.SLIDING_CONTENT as slideStyle; any other int throws IllegalArgumentException. The style controls whether the window decor (ActionBar area) or just the content view slides.","triggerScenarios":"Calling attachToActivity(activity, someInt) with a hand-written int, a misremembered constant, or a value from another library.","commonSituations":"Typing 0/1 literals instead of the constants; passing a constant from a different enum (e.g. touch mode); refactor renaming that dropped the constant reference.","solutions":["Pass SlidingMenu.SLIDING_WINDOW or SlidingMenu.SLIDING_CONTENT exactly","Use the two-arg attachToActivity(activity, slideStyle) overload with a valid constant","Check the call site for integer literals and replace with named constants"],"exampleFix":"// before\nslidingMenu.attachToActivity(this, 1);\n// after\nslidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);","handlingStrategy":"validation","validationCode":"if (slideStyle != SlidingMenu.SLIDING_WINDOW && slideStyle != SlidingMenu.SLIDING_CONTENT) throw new IllegalArgumentException(\"invalid slideStyle\");","typeGuard":null,"tryCatchPattern":"try { menu.attachToActivity(this, slideStyle); } catch (IllegalArgumentException e) { menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); }","preventionTips":["Always use the named constants, never int literals","Watch constant imports from wrong classes","Keep attach style centralized in one helper method"],"tags":["android","slidingmenu","enum-argument","illegal-argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"4254feca3ece9397cd501921ee733f19ea0fdad8","analyzedAt":"2026-09-09T10:08:27.041Z","contentChangedAt":"2026-09-09T10:08:27.041Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}