java - How to show fragment on performing certain action -
this question has answer here:
- dynamic fragments in android 1 answer
actually developing app has navigation drawer ,i want use fragment instead of separate activities . want how can done? in advance.
check sample code.hope helps you.
<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.drawerlayout 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:fitssystemwindows="true" tools:opendrawer="start"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include layout="@layout/toolbar_layout"> <!--the toolbar layout if have toolbar--> </include> <framelayout android:id="@+id/base_container" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> <!--the layout need add different fragments on click of nabigation items--> </framelayout> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="start" android:orientation="vertical"> <!--the navigation drawer items--> </linearlayout>
Comments
Post a Comment