Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ dependencies {
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'de.hdodenhof:circleimageview:1.3.0'

}
19 changes: 19 additions & 0 deletions app/src/main/java/com/ps/materialnavdrawer/DrawerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ public ViewHolder(View itemView, int viewType) {

if (viewType == ROW_TYPE) {
ButterKnife.inject(this, itemView);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int position=getAdapterPosition()-1;
// Toast Clicked element ID
Toast.makeText(itemView.getContext(),"post-"+position,Toast.LENGTH_SHORT).show();
// Start New Activity based on item selected
/*if(position==0){
Intent i=new Intent(itemView.getContext(),Dashboard.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
itemView.getContext().startActivity(i);
}else if(position==1){
Intent i=new Intent(itemView.getContext(),Setting.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
itemView.getContext().startActivity(i);
}*/

}
});
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/ps/materialnavdrawer/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public void onCreate(Bundle savedInstanceState) {
setSupportActionBar(toolbar);

ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.app_name, R.string.app_name);
drawerLayout.setDrawerListener(drawerToggle);
// setDrawerListner has been deprecated use addDrawerListener instead
//drawerLayout.setDrawerListener(drawerToggle);
drawerLayout.addDrawerListener(drawerToggle);
drawerToggle.syncState();

List<String> rows = new ArrayList<>();
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
android:layout_height="match_parent"
android:layout_gravity="start"
android:scrollbars="vertical"
android:background="#FFFFFF"/>
android:background="#ECEFF1"/>

</android.support.v4.widget.DrawerLayout>
</android.support.v4.widget.DrawerLayout>
21 changes: 20 additions & 1 deletion app/src/main/res/layout/drawer_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,24 @@
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="@color/material_deep_teal_500">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="80dp"
android:layout_height="80dp"
app:border_color="@color/divider"
app:border_width="1dp"
android:id="@+id/drawer_header_image"
android:src="@mipmap/ic_launcher"
android:layout_marginTop="40dp"
android:layout_marginLeft="30dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User"
android:textColor="#ffffff"
android:id="@+id/drawer_header_text"
android:layout_marginLeft="30dp"
android:layout_below="@+id/drawer_header_image"/>

</RelativeLayout>
</RelativeLayout>
12 changes: 10 additions & 2 deletions app/src/main/res/layout/drawer_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="48dp">
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackground"
android:layout_marginBottom="2dp">

<ImageView
android:layout_width="32dp"
Expand All @@ -21,5 +23,11 @@
android:textAppearance="?android:attr/textAppearanceMedium"
android:singleLine="true"
android:id="@+id/drawer_row_text"/>

<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="#000000" />

</FrameLayout>
</FrameLayout>