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.
original text
Read More:
- SqlNullValueException: Data is Null. This method or property cannot be called on Null values.
- When the spring MVC project is running on idea, an error is reported when the controller is a null pointer
- org.apache.ibatis.type.TypeException: Error setting non null for parameter #4 with JdbcType null
- AAPT: error: ‘null‘ is incompatible with attribute button (attr) reference.
- The background object of thymeleaf is null, which solves the problem of error when the object is empty to get the property value
- Error:null value in entry: incrementalFolder=null
- In Struts2, the value read from the foreground JSP page is null
- nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a property
- Spring security failed to log in, error: there is no passwordencoder mapped for the ID “null”
- Use of HQL query.list () is a null pointer exception, but the database can find out the result
- The @ Autowired annotation in springboot is invalid in ordinary classes. How to solve and use the null pointer exception java.lang.nullpointerexception
- This (code, message, data: null) still exists after importing spring cloud project into Lombok; the data in the project is unrecognized
- Null hypothesis
- IntegrityError at ** NOT NULL constraint failed: learning_logs_topic.owner_id
- java.lang.UnsupportedOperationException: null
- ERROR 1048 (23000): Column ‘courseno‘ cannot be null
- @Value gets the configuration file value and returns null
- Flutter Error: Cannot run with sound null safety, because the following dependencies don‘t support
- [Vue warn]: Error in nextTick: “TypeError: Cannot read property ‘map‘ of null“