I\'m trying to create a navigation drawer activity so I can extend that activity and use the menu in all activities by following the answer given in this question Link but m
The problem appears that the base class is not aware of the layout. Not sure how or why it worked for others without having to do something like this.. but I am new to Android.
I was getting the same error and solved by passing my layout to the base via onCreate.
So in the base, I modified onCreate to be like this:
protected void onCreate(Bundle savedInstanceState, int resLayoutID)
{
super.onCreate(savedInstanceState);
setContentView(resLayoutID);
Then, from my new activity, I have this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState, R.layout.my_activity);
This code in my base now works instead of staying null:
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerList = (ListView) findViewById(R.id.left_drawer);
btw, this result was suggested to me by a friend and it worked for me.