We use getactionbar to get the actionbar instance, hide it or do other operations.
ActionBar actionBar = getActionBar();
But I did, but actionbar is null.
The problem is caused by the base class of activity. When using the base class of appcompatactivity or other support packages, you need to use another corresponding method to get the actionbar instance, that is, getsupportactionbar (), and the actionbar also needs to use the base class of the corresponding support package.
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
In this way, the null pointer will not be reported.
- [Android] using request window feature（ Window.FEATURE_ NO_ Title) method to remove the title invalid solution
- Error record: this.requestWindowFeature ( Window.FEATURE_ NO_ Title) error or no effect
- Android set request window feature（ Window.FEATURE_ NO_ Title) invalid solution
- Request window feature for Android Development（ Window.FEATURE_ NO_ Title) does not take effect
- Execution failed for task ‘:app:processDebugManifest’
- AppCompat does not support the current theme features
- An error is reported for the new Android project. Rejecting re init on previously failed
- [solved] not found android.support .v7. internal.app.WindowDecorActionbar
- Failure delivering result ResultInfo
- Android appears java.lang.NoClassDefFoundError A solution to the error
- [error log] 27.1.0 series of errors Error:Failed to resolve: com.android.support :support-an notations:27.1.0
- After the go pointer is declared and assigned, a panic: runtime error: invalid memory address or nil pointer reference appears
- Failed to load AppCompat ActionBar with unknown error
- java.lang.IllegalStateException: Could not execute method for android:onClick
- Get the startup activity of Android apk
- AAPT: error: ‘null‘ is incompatible with attribute button (attr) reference.
- XML tag has empty body less… (Ctrl+F1) Reports empty tag body. The validation works in XML / JSP
- Android error java.lang.IllegalStateException : System services not available to Activities before onC
- Causes and solutions of classnotfoundexception / NoClassDefFoundError
- Java and Android commons codec usage and nosuch method error