title: How to add image on header in Navigation Drawer
body: <p>I am using Gabriele Mariotti navigation drawer library to create the sliding menu. It works perfect, but I'm facing with adding an image, as header in it. It should look something like this: </p>
  
  <p><img src="https://i.stack.imgur.com/uaOKk.jpg" alt="enter image description here"></p>
  
  <p>I mean.. not exactly the same, but the idea of having the image as header. Thanks !</p>
  
  <p><strong>MainActivity:</strong></p>
  
  <pre><code>package ro.volunteer;
  
  
  
  import android.app.Activity;
  import android.content.Intent;
  import android.content.res.Configuration;
  import android.media.MediaPlayer;
  import android.os.Bundle;
  import android.support.v4.app.ActionBarDrawerToggle;
  import android.support.v4.view.GravityCompat;
  import android.support.v4.widget.DrawerLayout;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.AdapterView;
  import android.widget.ListView;
  
  public class NewsFeed extends Activity implements OnClickListener {
  
      private ListView mDrawerList;
      private DrawerLayout mDrawer;
      private CustomActionBarDrawerToggle mDrawerToggle;
      private String[] menuItems;
  
  
      MediaPlayer player;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.newsfeed);
  
  
          // enable ActionBar app icon to behave as action to toggle nav drawer
          getActionBar().setDisplayHomeAsUpEnabled(true);
          getActionBar().setHomeButtonEnabled(true);
  
          mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  
          // set a custom shadow that overlays the main content when the drawer
          // opens
          mDrawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
  
          _initMenu();
          mDrawerToggle = new CustomActionBarDrawerToggle(this, mDrawer);
          mDrawer.setDrawerListener(mDrawerToggle);
      }
  
  
      private void _initMenu() {
          NsMenuAdapter mAdapter = new NsMenuAdapter(this);
  
  
  
          menuItems = getResources().getStringArray(
                  R.array.ns_menu_items_icon);
  
  
          // Add Header
          mAdapter.addHeader(R.string.ns_menu_main_header);
  
          // Add first block
  
          menuItems = getResources().getStringArray(
                  R.array.ns_menu_items);
          String[] menuItemsIcon = getResources().getStringArray(
                  R.array.ns_menu_items_icon);
  
          int res = 0;
          for (String item : menuItems) {
  
              int id_title = getResources().getIdentifier(item, "string",
                      this.getPackageName());
              int id_icon = getResources().getIdentifier(menuItemsIcon[res],
                      "drawable", this.getPackageName());
  
              NsMenuItemModel mItem = new NsMenuItemModel(id_title, id_icon);
              if (res==1) mItem.counter=0; //it is just an example...
              if (res==3) mItem.counter=0; //it is just an example...
              mAdapter.addItem(mItem);
              res++;
          }
  
          mAdapter.addHeader(R.string.ns_menu_main_header2);
  
          menuItems = getResources().getStringArray(
                  R.array.ns_menu_items2);
          String[] menuItemsIcon1 = getResources().getStringArray(
                  R.array.ns_menu_items_icon3);
  
          int res2 = 0;
          for (String item : menuItems) {
  
              int id_title = getResources().getIdentifier(item, "string",
                      this.getPackageName());
              int id_icon = getResources().getIdentifier(menuItemsIcon1[res2],
                      "drawable", this.getPackageName());
  
              NsMenuItemModel mItem = new NsMenuItemModel(id_title, id_icon);
              if (res2==1) mItem.counter=0; //it is just an example...
              mAdapter.addItem(mItem);
              res2++;
          }
  
          mDrawerList = (ListView) findViewById(R.id.drawer);
          if (mDrawerList != null)
              mDrawerList.setAdapter(mAdapter);
  
          mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
  
      }
  
  
      @Override
      protected void onPostCreate(Bundle savedInstanceState) {
          super.onPostCreate(savedInstanceState);
          // Sync the toggle state after onRestoreInstanceState has occurred.
          mDrawerToggle.syncState();
      }
  
      @Override
      public void onConfigurationChanged(Configuration newConfig) {
          super.onConfigurationChanged(newConfig);
          mDrawerToggle.onConfigurationChanged(newConfig);
      }
  
  
  
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          /*
           * The action bar home/up should open or close the drawer.
           * ActionBarDrawerToggle will take care of this.
           */
          if (mDrawerToggle.onOptionsItemSelected(item)) {
              return true;
          }
  
          // Handle your other action bar items...
          return super.onOptionsItemSelected(item);
      }
  
      private class CustomActionBarDrawerToggle extends ActionBarDrawerToggle {
  
          public CustomActionBarDrawerToggle(Activity mActivity,DrawerLayout mDrawerLayout){
              super(
                  mActivity,
                  mDrawerLayout, 
                  R.drawable.ic_drawer,
                  R.string.ns_menu_open, 
                  R.string.ns_menu_close);
          }
  
          @Override
          public void onDrawerClosed(View view) {
              getActionBar().setTitle(getString(R.string.ns_menu_close));
              invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
          }
  
          @Override
          public void onDrawerOpened(View drawerView) {
              getActionBar().setTitle(getString(R.string.ns_menu_open));
              invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
          }
      }
  
      private class DrawerItemClickListener implements ListView.OnItemClickListener {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              mDrawerList.setItemChecked(position, true);         
              mDrawer.closeDrawer(mDrawerList);
              if (position == 1) {
                  Intent intent = new Intent(NewsFeed.this, Profile.class);
                  startActivity(intent);
                  mDrawer.closeDrawers();
              }
  
  
          }
  
  
  
      }
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
  
      }
          }
  </code></pre>
  
  <p><strong>Adapter:</strong></p>
  
  <pre><code> package ro.volunteer;
  
  
      import android.content.Context;
      import android.graphics.Color;
      import android.view.LayoutInflater;
      import android.view.View;
      import android.view.ViewGroup;
      import android.widget.ArrayAdapter;
      import android.widget.ImageView;
      import android.widget.TextView;
  
      public class NsMenuAdapter extends ArrayAdapter&lt;NsMenuItemModel&gt; {
  
          /*
           * public NsMenuAdapter(Context context, int resource, int
           * textViewResourceId, String[] objects) { super(context,
           * R.layout.ns_menu_row, textViewResourceId, objects); }
           */
  
          public NsMenuAdapter(Context context) {
              super(context, 0);
          }
  
          public void addHeader(int title) {
              add(new NsMenuItemModel(title, -1, true));
          }
  
          public void addItem(int title, int icon) {
              add(new NsMenuItemModel(title, icon, false));
          }
  
          public void addItem(NsMenuItemModel itemModel) {
              add(itemModel);
  
          }
  
          @Override
          public int getViewTypeCount() {
              return 2;
          }
  
          @Override
          public int getItemViewType(int position) {
              return getItem(position).isHeader ? 0 : 1;
          }
  
          @Override
          public boolean isEnabled(int position) {
              return !getItem(position).isHeader;
          }
  
          public static class ViewHolder {
              public final TextView textHolder;
              public final ImageView imageHolder;
              public final TextView textCounterHolder;
  
              public ViewHolder(TextView text1, ImageView image1,TextView textcounter1) {
                  this.textHolder = text1;
                  this.imageHolder = image1;
                  this.textCounterHolder=textcounter1;
              }
          }
  
          public View getView(int position, View convertView, ViewGroup parent) {
  
              NsMenuItemModel item = getItem(position);
              ViewHolder holder = null;
              View view = convertView;
  
              if (view == null) {
                  int layout = R.layout.ns_menu_row_counter;
                  if (item.isHeader)
                      layout = R.layout.ns_menu_row_header;
  
                  view = LayoutInflater.from(getContext()).inflate(layout, null);
  
                  TextView text1 = (TextView) view.findViewById(R.id.menurow_title);
                  text1.setTextColor(Color.WHITE);
  
                  ImageView image1 = (ImageView) view.findViewById(R.id.menurow_icon);
                  TextView textcounter1 = (TextView) view.findViewById(R.id.menurow_counter);
  
                  view.setTag(new ViewHolder(text1, image1,textcounter1));
              }
  
              if (holder == null &amp;&amp; view != null) {
                  Object tag = view.getTag();
                  if (tag instanceof ViewHolder) {
                      holder = (ViewHolder) tag;
                  }
              }
  
  
              if(item != null &amp;&amp; holder != null)
              {
                  if (holder.textHolder != null)
                      holder.textHolder.setText(item.title);
  
                  if (holder.textCounterHolder != null){
                      if (item.counter &gt; 0){
                          holder.textCounterHolder.setVisibility(View.VISIBLE);
                          holder.textCounterHolder.setText(""+item.counter);
                      }else{
                          holder.textCounterHolder.setVisibility(View.GONE);
                      }
                  }
  
                  if (holder.imageHolder != null) {
                      if (item.iconRes &gt; 0) {
                          holder.imageHolder.setVisibility(View.VISIBLE);
                          holder.imageHolder.setImageResource(item.iconRes);
                      } else {
                          holder.imageHolder.setVisibility(View.GONE);
                      }
                  }
              }
  
              return view;        
          }
  
      }
  
  
  
  **ItemModel:**
  
  
  package ro.volunteer;
  
  
  public class NsMenuItemModel {
  
      public int title;
      public int iconRes;
      public int counter;
      public boolean isHeader;
  
      public NsMenuItemModel(int title, int iconRes,boolean header,int counter) {
          this.title = title;
          this.iconRes = iconRes;
          this.isHeader=header;
          this.counter=counter;
      }
  
      public NsMenuItemModel(int title, int iconRes,boolean header){
          this(title,iconRes,header,0);
      }
  
      public NsMenuItemModel(int title, int iconRes) {
          this(title,iconRes,false);
      }
  
  
  
  }
  </code></pre>