0

I have a Activity that has two NavigationDrawers one on each side. I wanted to clean this up and pull both menus out into their own xml file and use include to reference them in the main xml. This works for the left drawer but not the Right.

<include
    android:id="@+id/friendsInclude"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/friend_feed" 
    android:layout_gravity="start"/>

<!-- Notification Feed -->

<include
    android:id="@+id/notificationInclude"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/notification_feed"
    android:layout_gravity="end" />

Both have their own XML with the root layout being a Relative layout. They look like this..

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
    xmlns:fontawesometext="http://schemas.android.com/apk/res-auto"
    xmlns:bootstrapthumbnail="http://schemas.android.com/apk/res-auto"
    android:id="@+id/friendsLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start" 
    android:background="#F5F5F5">

and

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
    xmlns:fontawesometext="http://schemas.android.com/apk/res-auto"
    xmlns:bootstrapthumbnail="http://schemas.android.com/apk/res-auto"
    android:id="@+id/notificationsLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="end"
    android:background="#F5F5F5" >

In our main activity we get a null pointer when trying to open the right drawer via the action bar.

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    // Pass the event to ActionBarDrawerToggle, if it returns
    // true, then it has handled the app icon touch event
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }

    if(item.getItemId() == R.id.notifications) {

        if(drawerLayout.isDrawerVisible(notificationsLayout)) { //nullpointer
            drawerLayout.closeDrawer(notificationsLayout);
        } else {
            drawerLayout.openDrawer(notificationsLayout);
            drawerLayout.closeDrawer(friendsLayout);
        }
    }

    if(item.getItemId() == R.id.refresh) {
        new AsyncMainFeed(this).execute("");
        new AsyncFriendFeed().execute("");
        new AsyncNotificationFeed(this).execute("");
    }
    // Handle your other action bar items...

    return super.onOptionsItemSelected(item);
}

And I declare my layouts like this

    friendsLayout = (RelativeLayout)findViewById(R.id.friendsLayout);
    notificationsLayout = (RelativeLayout)findViewById(R.id.notificationsLayout);

I'm kinda stumped on where this is coming from any ideas?

Ravi
  • 34,851
  • 21
  • 122
  • 183
Mintybacon
  • 331
  • 2
  • 4
  • 11
  • Try looking through this post : http://stackoverflow.com/questions/17861755/drawerlayout-double-drawer-left-and-right-drawers-simultaneously Hope it helps – Daniel M. Jan 21 '14 at 23:37
  • I have the logic for opening closing. My problem is opening the right view no matter what state its in. I can be viewing the main feed access the right drawer and it crashes before it swipes on screen – Mintybacon Jan 23 '14 at 18:13

0 Answers0