NullPointerException: with ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference
来源:互联网 发布:java常考面试题 编辑:程序博客网 时间:2024/04/30 08:52
The cause of your issue is using MainActivity extend Activity
with support theme style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"
. It's incompatible things. Which min sdk you need?
In your code having MainActivity extends Activity
you don't need AppCompatTheme
. Use name="AppTheme" parent="android:Theme.Light
"
If you are using Theme.AppCompat.Light.DarkActionBar
, you should extend your Activity
from AppCompatActivity
, and use getSupportActionBar()
.
Instead of:
public class MainActivity extends Activity {
use:
public class MainActivity extends AppCompatActivity {
and instead of:
getActionBar().setTitle(mTitles);
use:
getSupportActionBar().setTitle(mTitles);
0 0
- NullPointerException: with ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference
- java.lang.NullPointerException:Attempt to invoke virtual method xxx on a null object reference
- java.lang.NullPointerException:TextView.setText(java.lang.CharSequence)' on a null object reference
- Attempt to invoke virtual method 'void android.app.ActionBar.hide()' on a null object reference
- Attempt to invoke virtual method 'void android.app.ActionBar.hide()' on a null object reference
- Attempt to invoke virtual method 'void android.app.ActionBar.hide()' on a null object reference
- "on a null object reference"问题解决方案
- on a null object reference 错误
- 关于PinnedHeaderExpandableListView使用的时候on a null object reference
- on a null object reference 问题的解决办法
- android.content.Context.getContentResolver()' on a null object reference错误
- monkey: android viewpager.offset on a null object reference
- ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference
- 'int android.graphics.Bitmap.getWidth()' on a null object reference
- 空指针on a null object reference问题
- findViewById出现错误View.isRootNamespace()' on a null object reference
- Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on
- Attempt to invoke interface method 'boolean android.database.Cursor.requery()' on a null object refe
- 数据结构 第五章 数组和广义表
- Webpack学习之哥们入个门呗(一)
- 第五届蓝桥杯B组Java—分糖果
- 2016蓝桥杯省赛 方格填数
- TortoiseGit 使用教程
- NullPointerException: with ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference
- 核桃的数量
- python模块之模块用于定义
- php基础题
- java-方法重载与方法重写
- Mac 安装jdk,并关联eclipse 记录
- Linux_Linux Shell 用curl 发送请求
- Dubbo的使用及原理浅析.
- (java)leetcode-27