Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. <FrameLayout
  2. android:id="@+id/content_frame"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. >
  6.  
  7. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  8. xmlns:app="http://schemas.android.com/apk/res-auto"
  9. xmlns:tools="http://schemas.android.com/tools"
  10. android:layout_width="match_parent"
  11. android:layout_height="match_parent"
  12. android:background="@color/viewBg"
  13. app:layout_behavior="@string/appbar_scrolling_view_behavior"
  14. tools:context="com.ss.bhagwanchalisa.MainActivity"
  15. tools:showIn="@layout/activity_main">
  16.  
  17. <android.support.v7.widget.RecyclerView
  18. android:id="@+id/recycler_view"
  19. android:layout_width="match_parent"
  20. android:layout_height="wrap_content"
  21. android:clipToPadding="false"
  22. android:scrollbars="vertical" />
  23.  
  24. </RelativeLayout>
  25. </FrameLayout>
  26. </RelativeLayout>
  27.  
  28. public class FirstFragment extends Fragment {
  29. View view;
  30. @Nullable
  31. @Override
  32. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  33. view=inflater.inflate(R.layout.firstlayout,container,false);
  34. return view;
  35.  
  36. }
  37. }
  38.  
  39. public boolean onNavigationItemSelected(MenuItem item) {
  40.  
  41. // Handle navigation view item clicks here.
  42. int id = item.getItemId();
  43. android.app.FragmentManager fragmentManager=getFragmentManager();
  44. Fragment f= new FirstFragment();
  45. FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  46. if (id == R.id.nav_camera) {
  47.  
  48. fragmentTransaction.replace(R.id.content_frame, f);
  49.  
  50. fragmentTransaction.commit();
  51.  
  52. Snackbar s=Snackbar.make(c ,"Hey",Snackbar.LENGTH_SHORT);
  53. s.show();
  54. } else if (id == R.id.nav_gallery) {
  55. fragmentManager.beginTransaction().replace(R.id.content_frame,new SecondFragment()).commit();
  56.  
  57. } else if (id == R.id.nav_slideshow) {
  58. fragmentManager.beginTransaction().replace(R.id.content_frame,new ThirdFragment()).commit();
  59. } else if (id == R.id.nav_share) {
  60.  
  61. } else if (id == R.id.nav_send) {
  62.  
  63. }
  64.  
  65. DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  66. drawer.closeDrawer(GravityCompat.START);
  67. return true;
  68. }
  69.  
  70. <TextView
  71. android:layout_width="wrap_content"
  72. android:layout_height="wrap_content"
  73. android:textAppearance="?android:attr/textAppearanceLarge"
  74. android:text="First"
  75. android:id="@+id/textView2"
  76. android:layout_gravity="center_horizontal"
  77. android:layout_alignParentTop="true"
  78. android:layout_centerHorizontal="true"
  79. android:layout_marginTop="198dp" />
  80. <Button
  81. android:layout_width="match_parent"
  82. android:layout_height="wrap_content"
  83. android:id="@+id/b1"
  84. android:text="Click" />
  85.  
  86. </RelativeLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement