0

I use this tutorial to make Navigation Drawer: http://www.tutecentral.com/android-custom-navigation-drawer/

so now i want to add my navigation to other activities but unfortunately i cant. i also follow this : How to Display Navigation Drawer in all activities?

and do this on my second activity but it have some error:

package com.example.uniapp;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class ShowAll extends Description {
MyDatabase MyDataBase;
SQLiteDatabase mydb;
TextView title,content;
ImageView image;


@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View contentView = inflater.inflate(R.layout.showall, null, false);
    mDrawerLayout.addView(contentView, 0); //null pointer error
  }
}

Do you have any suggestion?

Community
  • 1
  • 1
  • java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.uniapp/com.example.uniapp.ShowAll}: java.lang.NullPointerException 09-07 00:50:57.765: E/AndroidRuntime(11515): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2404) –  Sep 06 '15 at 20:22

1 Answers1

0

This means your drawerLayout is null. This is probably because it can;t find it. If you want your navigationdrawer in multiple activities, you also need to add the drawerLayout the all the activities its xml files.

Robin Dijkhof
  • 18,665
  • 11
  • 65
  • 116
  • thanks. but what do u mean by "add the drawerLayout in the all the activities its xml files" how can i add a layout in xml file? –  Sep 06 '15 at 20:28
  • I just do what ever they said. whats your point on that pages??? plz explain more thanks –  Sep 06 '15 at 20:39