Open Shahjahan786 opened 6 years ago
You should try
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Am getting same error after trying to add a custom dialog it started complaining about getSupportActionBar().setDisplayHomeAsUpEnabled(true); but was working fine
Am getting same error after trying to add a custom dialog it started complaining about getSupportActionBar().setDisplayHomeAsUpEnabled(true); but was working fine
It is not working for me
You should try this one. I think it will work.
Toolbar toolbar = findViewById(R.id.toolbar1);
setSupportActionBar(toolbar);
mDrawerLayout = findViewById(R.id.drawer_layout);
mDrawerLayout = findViewById(R.id.drawer_layout);
mDrawerLayout.setDrawerShadow(R.drawable.rectagle_with_black_outer,
GravityCompat.START);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
toolbar, R.string.navigation_drawer_close,
R.string.navigation_drawer_close) {
public void onDrawerClosed(View view) {
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
invalidateOptionsMenu();
}
};
Process: com.my.app, PID: 2142 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.app/droidninja.filepicker.FilePickerActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:203) at android.app.ActivityThread.main(ActivityThread.java:6251) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1073) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference at droidninja.filepicker.BaseFilePickerActivity.onCreate(BaseFilePickerActivity.java:27) at droidninja.filepicker.FilePickerActivity.onCreate(FilePickerActivity.java:26) at android.app.Activity.performCreate(Activity.java:6687) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:203) at android.app.ActivityThread.main(ActivityThread.java:6251) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1073) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:934)