You are on page 1of 31

MC Hybrid Flash Array

Flash Performance with Cost of


Disk. Watch Kevin Batty's Session.

Android Sliding Menu Using Navigation Drawer


In most of the android applications like Facebook , Google plus ,you tube, amazon kindle ,
true caller .. etc you have seen a side menu which appears on click of an icon on top left
corner or by dragging on to the screen from left to right , so here in this tutorial we shall see
how to create the sliding menu for you android application .

Note : Drawer Layout was added to Android Support Library, revision 19.0.1
Developer site : Support library

Design Pattern
Display
By swiping from the left edge of the screen.
By touching the application icon on the action bar.
Dismiss
Touching the app icon (at top left corner) .
Touching the content outside drawer .
Swapping anywhere on the Screen .
Pressing Back
For More Brief on design visit developer site Navigation Drawer . In this tutorial we will see
an example in which i have added three items for listview , onclick of any particular item of
the list , the corresponding content will be displayed . Below is the diagrammatic
representation .

While making this tutorial i was not able to import Drawer class ,reason i have not
updated the Development environment with support library so to do that follow the
below steps (do if you are not able to import drawer class or getting error ).
1. In Eclipse right-click over the project, then choose Android Tools > Add Support
Library
2. Accept License and then click Install.

DOWNLOAD CODE
Lets See An Example

Project Detail
Project Name

SlidingMenu

Package

com.pavan.slidingmenu

Minimum SDK API 8


Target SDK

API 17

Theme

Holo Light Theme

String Constant
Before i start coding i will initialize all the strings and arrays inside the inside
res/strings.xml. and also i have kept all the images inside the drawable folder of project.
file : strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">SlidingMenu</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="imgdesc">imgdesc</string>
<string-array name="titles">
<item>Facebook</item>
<item>Google-Plus</item>
<item>TutorialsBuzz</item>
</string-array>
<array name="icons">
<item>@drawable/fb</item>
<item>@drawable/gplus</item>
<item>@drawable/tb</item>
</array>
</resources>
I have edited the images and added to the drawable resource directory which you can find
inside the download source code.

drawable - mdpi (48*48) drawable - hdpi (72*72) drawable - xhdpi (96*96)

Main XML Layout


Create a main layout which contains DrawerLayout as parent view and add FrameLayout
and ListView as a child to it , the framelayout act as the main content view and listview act
as menu list
file : activity_main.xml
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- The main content view -->
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer list -->
<ListView
android:id="@+id/slider_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#ffffff"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>

ListView Set Up
I am setting up a Custom ListView for ListView Inside which contains one ImageView and
one TextView, so create list_item.xml inside layout directory ,this layout is used to defines
the design of each row items in a list view .
file : list_tem.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="48dp"
android:padding="5dp" >
<ImageView
android:id="@+id/icon"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:contentDescription="@string/imgdesc" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_toRightOf="@id/icon"
android:gravity="center_vertical"

android:textColor="#000000"
android:textSize="20sp" />
</RelativeLayout>

Bean Class
Create a Bean Class RowItem which is used for setting and getting row data's of each items
in ListView ( icons and titles).
file : RowItem.java
package com.pavan.slidingmenu;
public class RowItem {
private String title;
private int icon;
public RowItem(String title, int icon) {
this.title = title;
this.icon = icon;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getIcon() {
return icon;
}
public void setIcon(int icon) {
this.icon = icon;
}
}

Adapter
Create a Custom adapter which extends BaseAdapter , this is used for inflating each row
items of the listview .
file : CustomAdapter.java
package com.pavan.slidingmenu;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class CustomAdapter extends BaseAdapter {

Context context; List<RowItem> rowItem;


CustomAdapter(Context context, List<RowItem> rowItem) {
this.context = context;
this.rowItem = rowItem;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.list_item, null);
}
ImageView imgIcon = (ImageView) convertView.findViewById(R.id.icon);
TextView txtTitle = (TextView) convertView.findViewById(R.id.title);
RowItem row_pos = rowItem.get(position);
// setting the image resource and title
imgIcon.setImageResource(row_pos.getIcon());
txtTitle.setText(row_pos.getTitle());
return convertView;
}
@Override
public int getCount() {
return rowItem.size();
}
@Override
public Object getItem(int position) {
return rowItem.get(position);
}
@Override
public long getItemId(int position) {
return rowItem.indexOf(getItem(position));
}
}

Create Fragment for each Items of the ListView


Create fragment for each items of the listview , below you can see i have create fragment
for facebook item of listview.

ListView
Items

Fragments

XML Layout

Java Class

Facebook

fb_fragment.xml FB_Fragment.java

Google-Plus

gp_fragment.xml GP_Fragment.java

TutorialsBuzz tb_fragment.xml TB_Fragment.java


file : fb_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="148dp"
android:src="@drawable/fb" />
</RelativeLayout>
file : FB_Fragment.java
package com.pavan.slidingmenu.slidelist;
import com.pavan.slidingmenu.R;
import android.annotation.SuppressLint;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@SuppressLint("NewApi")
public class FB_Fragment extends Fragment {
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState)
{
View rootView = inflater .inflate(R.layout.fb_fragment, container, false);
return rootView;
}
}

Similarly Create Two More Fragments

Handling ListView Item click listener


Create a inner class called SlideitemListener , Inside the MainActivity class , and override
onItemClick method inside this method call updateDisplay() method by passing position as
a parameter to it and then inside updateDisplay by knowing the position clicked ,we are
replacing the current fragment with the respective fragment associated with the items of
listview . you can find the updateDisplay method inside the MainActivity class .

mDrawerList.setAdapter(adapter); mDrawerList.setOnItemClickListener(new
SlideitemListener()); ... ... ... class SlideitemListener implements

ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView parent, View view, int position, long id) {
updateDisplay(position);
}
}

Main Activity
file : MainActivity.java
package com.pavan.slidingmenu;
import java.util.ArrayList;
import java.util.List;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.pavan.slidingmenu.slidelist.FB_Fragment;
import com.pavan.slidingmenu.slidelist.GP_Fragment;
import com.pavan.slidingmenu.slidelist.TB_Fragment;
public class MainActivity extends Activity {
String[] menutitles; TypedArray menuIcons;
// nav drawer title
private CharSequence mDrawerTitle;
private CharSequence mTitle;
private DrawerLayout mDrawerLayout;
private ListView mDrawerList;
private ActionBarDrawerToggle mDrawerToggle;
private List<RowItem> rowItems;
private CustomAdapter adapter;
@SuppressLint("NewApi")
@Override protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);


mTitle = mDrawerTitle = getTitle();
menutitles = getResources().getStringArray(R.array.titles);
menuIcons = getResources().obtainTypedArray(R.array.icons);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.slider_list);
rowItems = new ArrayList<RowItem>();
for (int i = 0; i < menutitles.length; i++) {
RowItem items = new RowItem(menutitles[i], menuIcons.getResourceId( i, -1));
rowItems.add(items);
}
menuIcons.recycle();
adapter = new CustomAdapter(getApplicationContext(), rowItems);
mDrawerList.setAdapter(adapter);
mDrawerList.setOnItemClickListener(new SlideitemListener());
// enabling action bar app icon and behaving it as toggle button
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer, R.string.app_name,R.string.app_name)
{
public void onDrawerClosed(View view) {
getActionBar().setTitle(mTitle);
// calling onPrepareOptionsMenu() to show action bar icons
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(mDrawerTitle);
// calling onPrepareOptionsMenu() to hide action bar icons
invalidateOptionsMenu(); }
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
if (savedInstanceState == null) {
// on first time display view for first nav item
updateDisplay(0);
}
} class SlideitemListener implements ListView.OnItemClickListener {

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{ updateDisplay(position);
}
} private void updateDisplay(int position) {

Fragment fragment = null;


switch (position) {
case 0: fragment = new FB_Fragment();
break;
case 1: fragment = new GP_Fragment();
break;
case 2: fragment = new TB_Fragment();
break;
default:
break;
}
if (fragment != null) {
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.frame_container,
fragment).commit();
// update selected item and title, then close the drawer
setTitle(menutitles[position]);
mDrawerLayout.closeDrawer(mDrawerList);
}
else {
// error in creating fragment
Log.e("MainActivity", "Error in creating fragment");
}
}
@Override
public void setTitle(CharSequence title) {
mTitle = title; getActionBar().setTitle(mTitle);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// toggle nav drawer on selecting action bar app icon/title
if (mDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
// Handle action bar actions click
switch (item.getItemId()) {
case : R.id.action_settings
return true;
default :
return super.onOptionsItemSelected(item);
}
}
/*** * Called when invalidateOptionsMenu() is triggered */

@Override public boolean onPrepareOptionsMenu(Menu menu) {


// if nav drawer is opened, hide the action items
boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
menu.findItem(R.id.action_settings).setVisible(!drawerOpen);
return super.onPrepareOptionsMenu(menu);
}
/** * When using the ActionBarDrawerToggle, you must call it during * onPostCreate()
and onConfigurationChanged()... */
@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);
// Pass any configuration change to the drawer toggles
mDrawerToggle.onConfigurationChanged(newConfig);
}
}

Don't Miss : Sliding Menu With WebView .

More on Menus
1. Android Option Menu .
2. Android Context Menu .
3. Android Popup Menu .

11

96 comments:
Dheeraj 5 April 2014 at 00:41
Its working on api level 11 but i want to support android version 2.2
Reply

Desan Benz 8 April 2014 at 08:08


can you post me the code on same navigation drawer so that on clicking facebook of navigation
drawer, it goes to facebook activity and listview display
Reply
Replies
Pavan Deshpande 4 January 2015 at 22:30
@Desan Benz
Here it is sliding menu with webview
http://www.tutorialsbuzz.com/2014/07/android-sliding-menu-webview.html
Reply

Pavan Deshpande 8 April 2014 at 21:21


@Dheeraj
Navigation Drawer is supported from Android 1.6 (API level 4 , Donut ) and above ,
I hope you have missed to add support library
Stay tuned for updates by subscribing and also share with your friends
Reply

Pavan Deshpande 8 April 2014 at 21:22


@ Desan ,
Sure , i will post ,actually you need to use webview inside the fragment to achieve that
I will write a post which is not for facebook kind but generic to any web app
Stay tuned for updates by subscribing and also share with your friends
Reply

Anonymous 9 April 2014 at 05:59


can u plz tel how to make navigation drawer with checkbox and textview
Reply
Replies
Shivam Chauhan 9 February 2016 at 04:27
If i want to make an apprelated to notice board of my college how should i handle its
dbase?

Shivam Chauhan 9 February 2016 at 04:37


If i want to make an apprelated to notice board of my college how should i handle its
dbase?
Reply

Pavan Deshpande 9 April 2014 at 22:45


To add checkbox to the items of listview you can refer this post
http://www.tutorialsbuzz.com/2014/03/watsapp-custom-listview-imageview-textviewbaseadapter.html
Reply

Anonymous 10 April 2014 at 12:36


Can u tel me pls how to put an MusicPlayer inside the Navigation Drawer?I want Navigation
Drawer be like a SlidingDrawer, don.t want to have a menu(listview) inside...if you know what i
mean..:D
Reply

Anonymous 10 April 2014 at 13:13


I realize what i was doing wrong.i need to pun android:layout_gravity="start" in the relativelayout
who takes place of ListView.Thanks anyway,and gj with this tutorial:D
Reply

Dheeraj 11 April 2014 at 06:29


which library i needs to integrate...........?..but i dont want to integrate actionbar sharelock......
..
Reply

Pavan Deshpande 11 April 2014 at 07:33


@Dheeraj
follow this steps
1) In Eclipse right-click over the project, then choose Android Tools > Add Support Library
2) Accept License and then click Install
Reply

Matz0911 16 April 2014 at 08:52

man u are great !


thx for the code !
Reply

R.M PARTHI 17 April 2014 at 08:23


itz a great tutorial..
but im trying to create the navigation drawer at the bottom..
how to do it???
please do guide me...
Reply

Dheeraj Verma 19 April 2014 at 05:38


i am getting error in holo theme on menifest file when i click to add support library nothing
happen.... i m using latest sdk when still error...................
Reply

Izaz Hassan 30 April 2014 at 03:02


how can give margin from left to button in action bar from which menu appears as it is not
completely visible..
Reply

Mansoor Ahmad Samar 30 April 2014 at 04:42


Exellent tutorial.... very easy to understand. Thanks and keep sharing your Knowledge
Reply

Pavan Deshpande 30 April 2014 at 18:31


@Dheeraj Verma
you need to add support library for your eclipse , make sure it is added successfully or you can
check this link https://developer.android.com/tools/support-library/setup.html
Reply

Pavan Deshpande 30 April 2014 at 18:33


@Izaz Hassan
i think its not possible to set margin within the action bar , i will try to check and let u
Reply

Pavan Deshpande 30 April 2014 at 18:35


@Mansoor Ahmad Samar
Thank you :)
Please share with your friends and get in touch with my little blog through email , facebook ...
Reply

Nilesh Rambhad 1 May 2014 at 09:30


sir i am subscribe user but unable to get download this slider code
Reply

Pavan Deshpande 1 May 2014 at 10:56


@Nilesh Rambhad
I have updated the database now you can try , and let me know :)
Reply

Rohan Rathore 5 May 2014 at 05:01


i am subscribed user but unable to get download this slider code
Reply

D!b@k@r M!$try 5 May 2014 at 06:53


This comment has been removed by the author.
Reply

D!b@k@r M!$try 5 May 2014 at 06:55


my mail address is dibakar.ece@gmail.com ,but I'm not able to download your code.It show
me,sorry no email id found
Reply

Pavan Deshpande 5 May 2014 at 07:17


@Rohan Rathore
@Dibakar
I have updated the database now you can download , let me know if any issue
Reply

Mohammed moosa khan 7 May 2014 at 23:51


please could you update ur code .. how to fetch the data from the sqlite in the form of listview ,
custom view, and grid view....please i am waiting for ur reply bro....
Reply

Pavan Deshpande 8 May 2014 at 20:26


@Mohammed
Use SimpleCursorAdapter to get data from database , you can check this
http://www.tutorialsbuzz.com/2013/11/android-sqlite-database-with.html
any issue let me know
Reply

Zakarie Sheridan 12 May 2014 at 04:43


I'm not able to download your code, would you be able to update your database please!
Thank you :-)
Reply

Pavan Deshpande 12 May 2014 at 05:09


@zakarie
I have updated the database recently ,
and please do verification confirmation which is sent to your mail id
Thank you :)
Reply

suvarna deo 14 May 2014 at 04:33


Hello Pavan,
Please add me to database....

Reply

Pavan Deshpande 14 May 2014 at 20:15


@suvarna deo
The database is updated and yes you are in database , now you are able to download all the
resource of tutorialsbuzz
Reply

Pavan Deshpande 14 May 2014 at 20:20


Please do subscribe to my blog , its only one time subscription and every resource of this blog is
available once you subscribe
Thank you :)
Reply

Vincius Mendes 21 May 2014 at 18:13


Hello Pavan,
Please, can you accept me in your subscribe list ? I need to download the source code, but I need
to be updated in your database.
Thanks in advance,
Vincius Mendes de Souza.
Reply

Pavan Deshpande 21 May 2014 at 20:24


@Vincius Mendes
Yes you can download the code now
Reply

Ronna Erica Onting 21 May 2014 at 23:13


Hi Pavan,
Can you help me using this for activities instead of fragments. I've already done it, the only
problem is I can't achieve the slide effect. you may download it here:
http://www.4shared.com/rar/JBVBWAkKba/ShopNote.html
Reply

Aeonia 22 May 2014 at 02:40


Hello Pavan,
Kindly add me to your subscriber database..
Reply

ansy 30 May 2014 at 00:27

hw cn i display a map on clicking the map oprtion from the navigation drawer ?
Reply

soliman Eldebaky 2 June 2014 at 03:17


how to add it to right side
Reply

Stephan Celis 8 June 2014 at 01:23


Thank you for this tutorial.
Also small mistake I noticed when copy pasting.
'case : R.id.action_settings:' => one ':' to many, it should be 'case R.id.action_settings:'
Reply

Pavan Deshpande 10 June 2014 at 03:05


@Stephan
Thanks for Suggestion ,
I have updated
Reply

Aeonia 11 June 2014 at 02:22


hi, am having trouble adding a viewflipper animation that changes screen with every swipe to
one of my fragments..it was previously working but not after i added a navigation drawer..here is
the piece of code with error..
if (lastX > currentX) {
if (viewFlipper.getDisplayedChild() == 1)
break;
// set the required Animation type to ViewFlipper
// The Next screen will come in form Right and current Screen
// will go OUT from Left
viewFlipper.setInAnimation(this, R.anim.in_from_right);
viewFlipper.setOutAnimation(this, R.anim.out_to_left);
Error is: The method setInAnimation(Context, int) in the type ViewAnimator is not applicable for
the arguments (FR_Fragment, int)
Kindly assist..
Reply

Programmer 1 14 June 2014 at 19:04


HI, I subscribed but cant get access tot he code
Reply

Way2webworld 16 June 2014 at 00:41


You have used Theme.Holo.Light which is not supported in SDK Version 8. Once I changed the
Theme to android:Theme.Light application is showing error 06-16 07:33:42.734:
E/AndroidRuntime(866):
java.lang.RuntimeException:
Unable
to
start
activity
ComponentInfo{com.pavan.slidingmenu/com.pavan.slidingmenu.MainActivity}:
java.lang.NullPointerException
06-16
07:33:42.734:
E/AndroidRuntime(866):
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
Reply

Pavan Deshpande 16 June 2014 at 01:07


@way2webworld
Minimum is 8 and target is 17 , it lies within this
update your sdk
Reply

LondonNut.com 16 June 2014 at 08:30


Have subscribed and verified by email, but can't download it still says 'sorry no email id found'
Reply

KumarVarma 19 June 2014 at 05:17


Hi ... Please, can you accept me in your subscribe list. I need to download the source code.
Reply

Modan Mohammed Shahil 24 June 2014 at 09:42


Kindly add me to your subscriber database.
Reply

Alain Camacho 25 June 2014 at 07:39


Hello Pavan,
Please, can you accept me in your subscribe list ?

Thanks in advance,
Alain Camacho
Reply

Markus 26 June 2014 at 00:07


Can you please add me to your subscirber database.
Thanks
Reply

PN 1 July 2014 at 01:28


I got error in above code like activity_main,slider_list,titles,icon can not be resolved or is not a
field
Reply

PN 1 July 2014 at 01:31


This comment has been removed by the author.
Reply

Chris Cuevas 1 July 2014 at 09:47


I am confused, what is R.id.action_settings referring to, the string?
Reply

PN 2 July 2014 at 02:46


can you please help me to put content inside.
suppose i click on one navigation icon then i can see all the content about it.like if I click on
contact then all information about contact I can view.
Please help me to do.
Reply

Pavan Deshpande 2 July 2014 at 03:29


@PN
When you click of each item of slide menu a fragment associated with that menu item will be
opened , you can create a fragment which shows contact info and associate that fragment with
item of slide menu
Reply

PN 2 July 2014 at 19:35


Thanks for your reply
can you please send me one example suppose I want to add google map inside my
contact(navigation icon) so where I should do coding for it.
Reply

Pavan Deshpande 3 July 2014 at 01:22


@PN
Sure i will post google maps tutorial in my future blog post
Reply

PN 3 July 2014 at 01:43


Thanks.
Reply

PN 3 July 2014 at 01:51


I am still confused in how to add content inside the navigation icon.
If It possible to you please send small example
Thanks in advance
Reply

Moviezadda Bollywooduncut 3 July 2014 at 04:09


This sample is not working in Froyo and Honeycomb versions..
Reply

Pavan Deshpande 3 July 2014 at 04:26


@Moviezadda
Navigation Drawer Runs on Android 1.6 (API level 4) and up ,
you need to include support library (https://developer.android.com/tools/supportlibrary/index.html)
Reply

Ghayaz Rockingghayazcse 6 July 2014 at 13:49


how to get the same navigator drawer on right top corner
Reply

Vie Venesia 18 July 2014 at 03:20


How if want add button in the layout main activity?
Reply

Alberto Gaudicos Jr 18 July 2014 at 22:32


hi your code is working good, but i want an custom layout like your example above not only
listview on it but have an image... add me also, thanks!
Reply

Rohit Kashyap 2 August 2014 at 04:50


Hi,
This is indeed a great tutorial. But there is a bit problem when using drawer layout on the activity
other than root activity i.e. you can't see the image which is used to slide the menu.
for e.g. if suppose you have sequence of activities: A-->B , then you can't see the slider on the top
left corner of Activity B .
Reply

kumar 12 August 2014 at 06:08


How to show navigation button in all screens
Reply

Shobin Jindal 17 August 2014 at 22:58


I already subscribed but unable to get code......
Reply

Pavan Deshpande 17 August 2014 at 23:25


@Shobin Jindal
Database Updated you can download the code
Reply

Pavan Deshpande 21 August 2014 at 07:11


The database is updated you can download
For new Subscribers it's only one time subscription , after that you can download the full
resource of tutorialsbuzz

please new subscriber co-operate , it takes 9-10hrs to update for new subscription .
Reply

LEE JIAN HAO 7 September 2014 at 01:28


Hi Pavan, can u add me as subscribers, I need to download the source code for refer, thanks =)
Reply

Pavan Deshpande 7 September 2014 at 03:22


@LEE JIAN HAO
Database Updated you can download the code
Reply

LEE JIAN HAO 7 September 2014 at 06:25


Hi Pavan, I tried to download source code using my Email, but it shows "sorry no email id found",
is there any steps I missed out? thanks
Reply

essai 7 September 2014 at 14:06


Hello , I'd like to know how to add a search bar to this tutorial !!
I am very thankful for this great project ;)
Reply

Vishal King 18 September 2014 at 03:05


i am not able to download this code....
Reply

Pavan Deshpande 18 September 2014 at 20:04


@Vishal
DB is updated you can download
Reply

Osama Abd 29 September 2014 at 11:07

good job man .. but i want if i clicked in on facebook in the sliding menu it well open facebook
page or site or any webview ? how can i do that please ?
Reply

Pavan Deshpande 29 September 2014 at 20:11


@Osama Abd
Use Android WebView , I have already written about this here
http://www.tutorialsbuzz.com/2014/07/android-sliding-menu-webview.html
Reply

Martn Krahl Vitale 3 November 2014 at 18:14


@Pavan, I am not able to download the code, can you help me please?
Reply

Alan 20 November 2014 at 23:03


PLEASE how can i change the background color of the HEADER (the top navigation bar where
you have the google icon, title.. where you click to open the left side menu)? IT IS ALWAYS THIS
GRAY background.. HOW TO change it to a specific color such as #56F609 ?
Reply

Daniel 3 December 2014 at 19:41


Hi PAVAN Your blog is very nice,very easy to understand and nice way of explanation.
I Hope u can make more and more good tutorials like this.
Please Tell me About Navigation Drawer with Tabs by using Fragment Class ,like youtube and
Google+
Reply

Daniel 3 December 2014 at 19:42


Hi PAVAN Your blog is very nice,very easy to understand and nice way of explanation.
I Hope u can make more and more good tutorials like this.
Please Tell me About Navigation Drawer with Tabs by using Fragment Class ,like youtube and
Google+
Reply

Ashvin 19 January 2015 at 20:23


sorry no email id found
Reply

Replies
Pavan Deshpande 19 January 2015 at 20:52
@Ashvin
db is updated you can download , let me know any issue
Reply

Lupe Hdez L 7 February 2015 at 00:42


Thanks for your help, is perfect!!! :)
Reply

Daniel 9 February 2015 at 19:56


Thanks for your help
Reply

Daniel 11 February 2015 at 00:09


Hi PAVAN
Please Tell me About Navigation Drawer with Tabs (or) tab host by using Fragment Class ,like
you tube Sports page
Reply

Akshay Shah 17 February 2015 at 02:46


Hey !! Thanx so much for this tutorial , i tried using the way that you have shown but i am getting
some runtime error !! i'll paste my error log below !!

java.lang.RuntimeException:
Unable
to
start
activity
ComponentInfo{com.auberginesolutions.slidermenu/com.auberginesolutions.slidermenu.MainA
ctivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or
descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
at android.app.ActivityThread.access$700(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5283)
at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or
descendant) with this activity.
at
android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
at
android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase
.java:138)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
at com.auberginesolutions.slidermenu.MainActivity.onCreate(MainActivity.java:46)
at android.app.Activity.performCreate(Activity.java:5283)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
at android.app.ActivityThread.access$700(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5283)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Reply

loic diart 1 April 2015 at 02:36


hello,
It's perfect but i would like have much more annotation if you can do and resend me after that
will perfect :)
Thank
Reply

Priyanka Amrutkar 4 June 2015 at 02:15


i tried this code in android studio but getting error of getActionBar() throws null pointer exception
.. any one help me..
Reply
Replies

Nora Crosthwaite 12 August 2015 at 09:39


Hi -- I am having the same issue. Any ideas?

Priyanka Amrutkar 12 August 2015 at 22:31


Instead of using getActionBar() use getSupportActionBar().
Reply

Apurba Mondol 23 June 2015 at 04:08


On line no FragmentManager fragmentManager = getFragmentManager();
Type
mismatch:
cannot
convert
from
android.app.FragmentManager
android.support.v4.app.FragmentManager
show this type error please help me
Reply
Replies
Pawan Deshpande

23 June 2015 at 21:16

@Aprurba Mondol
Make sure to import
"import android.app.Fragment;
import android.app.FragmentManager;"
Instead of
"import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager"
Reply

Ashish Liverpool 12 July 2015 at 02:54


How to change the icon of default android with our own?
Reply

Ashish Liverpool 12 July 2015 at 02:54


How to change the image icon of android that is displayed on the top?
Reply

to

Reply

Enter your comment...

Comment as:

Publish

mohammad shoaib quraishi (Google)

Sign out

Notify me

Preview

Home

View web version

Powered by Blogger.

You might also like