Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <FrameLayout
- android:id="@+id/content_frame"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- >
- <RelativeLayout 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:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@color/viewBg"
- app:layout_behavior="@string/appbar_scrolling_view_behavior"
- tools:context="com.ss.bhagwanchalisa.MainActivity"
- tools:showIn="@layout/activity_main">
- <android.support.v7.widget.RecyclerView
- android:id="@+id/recycler_view"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:clipToPadding="false"
- android:scrollbars="vertical" />
- </RelativeLayout>
- </FrameLayout>
- </RelativeLayout>
- public class FirstFragment extends Fragment {
- View view;
- @Nullable
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- view=inflater.inflate(R.layout.firstlayout,container,false);
- return view;
- }
- }
- public boolean onNavigationItemSelected(MenuItem item) {
- // Handle navigation view item clicks here.
- int id = item.getItemId();
- android.app.FragmentManager fragmentManager=getFragmentManager();
- Fragment f= new FirstFragment();
- FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
- if (id == R.id.nav_camera) {
- fragmentTransaction.replace(R.id.content_frame, f);
- fragmentTransaction.commit();
- Snackbar s=Snackbar.make(c ,"Hey",Snackbar.LENGTH_SHORT);
- s.show();
- } else if (id == R.id.nav_gallery) {
- fragmentManager.beginTransaction().replace(R.id.content_frame,new SecondFragment()).commit();
- } else if (id == R.id.nav_slideshow) {
- fragmentManager.beginTransaction().replace(R.id.content_frame,new ThirdFragment()).commit();
- } else if (id == R.id.nav_share) {
- } else if (id == R.id.nav_send) {
- }
- DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
- drawer.closeDrawer(GravityCompat.START);
- return true;
- }
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:text="First"
- android:id="@+id/textView2"
- android:layout_gravity="center_horizontal"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_marginTop="198dp" />
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/b1"
- android:text="Click" />
- </RelativeLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement