I tried. I am unsuccessful. I am writing my steps. If anyone can help me out.
- Create New Project using Android Studio and selected "Navigation Drawer Activity"
I put FrameLayout inside main activity as below
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start"> <include layout="@layout/app_bar_vshome" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header_vshome" app:menu="@menu/activity_vshome_drawer" /> <!-- Framelayout to display Fragments --> <FrameLayout android:id="@+id/frame_container" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.v4.widget.DrawerLayout>
I made new class, as below using v4.app.Fragment
public class VSAllTopics extends Fragment{ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_all_topics, container, false); } }
I made Fragment Mananger, as below,
public class FragmentManager extends Fragment { }
calling in **public boolean onNavigationItemSelected(MenuItem item) **
android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); if (id == R.id.nav_camera) { ft.replace(R.id.frame_container, new VSAllTopics(), "VS_ALL").commit();
I studied a little but I could not get succeed. It is not calling.
If I call it through Intent, it removes NAVIGATION ;(
HOW CAN I USE SIDE MENU IN A PROPER MANER.
THANKS.