left_drawer.xml
<?xml version="1.0"
encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/slide_me_lay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/lvtop"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/txt_Title"
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#d44a48"
android:paddingLeft="20dp"
android:paddingTop="30dp"
android:text="Drawerapp"
android:textColor="#ffffff"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rvmiddle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@+id/lvtop">
<RelativeLayout
android:id="@+id/rlvdashboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp">
<ImageView
android:id="@+id/img1"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:background="@drawable/icdashboard" />
<TextView
android:id="@+id/txtdashboard"
android:layout_width="250dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/img1"
android:text="DASHBOARD"
android:textColor="@android:color/black"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlvprofile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rlvdashboard"
android:padding="3dp">
<ImageView
android:id="@+id/img2"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:background="@drawable/icprofile"
/>
<TextView
android:id="@+id/txtprofile"
android:layout_width="250dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/img2"
android:text="PROFILE"
android:layout_marginLeft="5dp"
android:textColor="@android:color/black"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlvproducts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rlvprofile"
android:padding="3dp">
<ImageView
android:id="@+id/img3"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_margin="10dp"
android:layout_centerVertical="true"
android:background="@drawable/icproducts" />
<TextView
android:id="@+id/txtproducts"
android:layout_width="250dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/img3"
android:text="PRODUCTS"
android:layout_marginLeft="5dp"
android:textColor="@android:color/black"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlvaccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rlvproducts"
android:padding="3dp">
<ImageView
android:id="@+id/img4"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:background="@drawable/icaccounts" />
<TextView
android:id="@+id/txtaccount"
android:layout_width="250dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/img4"
android:text="ACCOUNTS"
android:layout_marginLeft="5dp"
android:textColor="@android:color/black"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlvcoupon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rlvaccount"
android:padding="3dp">
<ImageView
android:id="@+id/img5"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:background="@drawable/icsetting" />
<TextView
android:id="@+id/txtcoupon"
android:layout_width="250dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/img5"
android:text="COUPONS"
android:layout_marginLeft="5dp"
android:textColor="@android:color/black"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlvtransaction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rlvcoupon"
android:padding="3dp">
<ImageView
android:id="@+id/img6"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:background="@drawable/icsetting" />
<TextView
android:id="@+id/txttransaction"
android:layout_width="250dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/img6"
android:text="TRANSACTIONS"
android:layout_marginLeft="5dp"
android:textColor="@android:color/black"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlvwallet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rlvtransaction"
android:padding="3dp">
<ImageView
android:id="@+id/img7"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:background="@drawable/icsetting" />
<TextView
android:id="@+id/txtwallet"
android:layout_width="250dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/img7"
android:text="WALLET"
android:layout_marginLeft="5dp"
android:textColor="@android:color/black"
android:textSize="15sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rlvsettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/rlvwallet"
android:padding="3dp">
<ImageView
android:id="@+id/img8"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_margin="10dp"
android:background="@drawable/icsetting" />
<TextView
android:id="@+id/txtsettings"
android:layout_width="250dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/img8"
android:text="SETTINGS"
android:layout_marginLeft="5dp"
android:textColor="@android:color/black"
android:textSize="15sp" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
MainActivity.java
package com.tikarye.mydrawerapp;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import com.navdrawer.SimpleSideDrawer;
import java.util.Map;
public class MainActivity extends Activity {
//String TAG = getClass().getName();
private TabHost tabHost;
Intent i;
ImageView ivDrawer;
RelativeLayout header, rvdashboard, rvprofile, rvproduct, rvaccount, rvsetting;
TextView tv_dashboard, tv_profile, tv_products, tv_account, tv_setting;
Map<String, String> mapActivityTitles;
SimpleSideDrawer slide_me_left;
LinearLayout slide_me_lay;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_actionbar);
header = (RelativeLayout) findViewById(R.id.header);
slide_me_left = new SimpleSideDrawer(this);
slide_me_left.setLeftBehindContentView(R.layout.left_drawer);
//drawer
ivDrawer = (ImageView) findViewById(R.id.img_drawer);
tv_dashboard = (TextView) findViewById(R.id.txtdashboard);
tv_profile = (TextView) findViewById(R.id.txtprofile);
tv_products = (TextView) findViewById(R.id.txtproducts);
tv_account = (TextView) findViewById(R.id.txtaccount);
tv_setting = (TextView) findViewById(R.id.txtcoupon);
rvdashboard = (RelativeLayout) findViewById(R.id.rlvdashboard);
rvprofile = (RelativeLayout) findViewById(R.id.rlvprofile);
rvproduct = (RelativeLayout) findViewById(R.id.rlvproducts);
rvaccount = (RelativeLayout) findViewById(R.id.rlvaccount);
rvsetting = (RelativeLayout) findViewById(R.id.rlvcoupon);
ivDrawer.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
slide_me_left.toggleLeftDrawer();
Toast.makeText(getApplicationContext(), "left", Toast.LENGTH_SHORT).show();
return false;
}
});
rvdashboard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
i = new Intent(getApplicationContext(), Act_Dashboard.class);
startActivity(i);
finish();
}
});
rvprofile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
i = new Intent(getApplicationContext(), Act_Profile.class);
startActivity(i);
finish();
}
});
rvproduct.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "product", Toast.LENGTH_SHORT).show();
}
});
rvaccount.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "account", Toast.LENGTH_SHORT).show();
}
});
rvsetting.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "setting", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onBackPressed() {
/*if(isMenuOpened())
closeMenu();
else*/
super.onBackPressed();
}
}
custom_actionbar_walletrs.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#ffffff">
<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#d44a48">
<ImageView
android:id="@+id/img_drawer"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="2dp"
android:layout_marginTop="3dp"
android:contentDescription="@string/app_name"
android:src="@drawable/menu" />
<TextView
android:id="@+id/header_title_wallet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="50dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="@+id/img_drawer"
android:gravity="left"
android:text="TITLE"
android:textColor="#FFFFFFFF"
android:textSize="20dp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:orientation="vertical">
<TextView
android:id="@+id/walletrs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="WALLET BALANCE"
android:textColor="#FFFFFFFF"
android:textSize="10dp" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_below="@+id/walletrs"
android:layout_marginTop="5dp"
android:layout_toLeftOf="@+id/amount"
android:background="@drawable/rupee" />
<TextView
android:id="@+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/walletrs"
android:text="1000"
android:textColor="#FFFFFFFF"
android:textSize="20sp" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/contentOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/header"
android:background="@android:color/transparent"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
dashboard.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
<include
layout="@layout/custom_actionbar_walletrs"></include>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="dashboard"
android:textSize="15sp" />
</RelativeLayout>
Act_Dashboard.java
package com.tikarye.mydrawerapp;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import com.navdrawer.SimpleSideDrawer;
import java.util.Map;
public class Act_Dashboard extends Activity {
private TabHost tabHost;
Intent i;
ImageView ivDrawer;
RelativeLayout rvdashboard, rvprofile, rvproduct, rvaccount, rvsetting;
TextView tv_dashboard, tv_profile, tv_products, tv_account, tv_setting, header_wallet;
Map<String, String> mapActivityTitles;
SimpleSideDrawer slide_me_left;
LinearLayout slide_me_lay;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dashboard);
//header = (TextView) findViewById(R.id.header_title);
header_wallet = (TextView) findViewById(R.id.header_title_wallet);
slide_me_left = new SimpleSideDrawer(this);
slide_me_left.setLeftBehindContentView(R.layout.left_drawer);
//drawer
ivDrawer = (ImageView) findViewById(R.id.img_drawer);
tv_dashboard = (TextView) findViewById(R.id.txtdashboard);
tv_profile = (TextView) findViewById(R.id.txtprofile);
tv_products = (TextView) findViewById(R.id.txtproducts);
tv_account = (TextView) findViewById(R.id.txtaccount);
tv_setting = (TextView) findViewById(R.id.txtcoupon);
rvdashboard = (RelativeLayout) findViewById(R.id.rlvdashboard);
rvprofile = (RelativeLayout) findViewById(R.id.rlvprofile);
rvproduct = (RelativeLayout) findViewById(R.id.rlvproducts);
rvaccount = (RelativeLayout) findViewById(R.id.rlvaccount);
rvsetting = (RelativeLayout) findViewById(R.id.rlvcoupon);
header_wallet.setText("DASHBOARD");
ivDrawer.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
slide_me_left.toggleLeftDrawer();
Toast.makeText(getApplicationContext(), "left", Toast.LENGTH_SHORT).show();
return false;
}
});
rvdashboard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
i = new Intent(getApplicationContext(), Act_Dashboard.class);
startActivity(i);
finish();
}
});
rvprofile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
i = new Intent(getApplicationContext(), Act_Profile.class);
startActivity(i);
finish();
}
});
rvproduct.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "product", Toast.LENGTH_SHORT).show();
}
});
rvaccount.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "account", Toast.LENGTH_SHORT).show();
}
});
rvsetting.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "setting", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onBackPressed() {
startActivity(new Intent(getApplicationContext(), MainActivity.class));
finish();
}
}
Final Output
Feel free to post your comments, queries and suggestions
Cheers...:-)