Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. private class SlideMenuClickListener implements
  2. ListView.OnItemClickListener {
  3. @Override
  4. public void onItemClick(AdapterView<?> parent, View view, int position,
  5. long id) {
  6. // display view for selected nav drawer item
  7. displayView(position);
  8. }
  9. }
  10.  
  11.  
  12. private void displayView(int position) {
  13. // update the main content by replacing fragments
  14. Fragment fragment = null;
  15. switch (position) {
  16. case 0:
  17. fragment = new GalleryFragment();
  18. break;
  19. case 1:
  20. fragment = new FindPeopleFragment();
  21. break;
  22. case 2:
  23. fragment = new PhotosFragment();
  24. break;
  25.  
  26. default:
  27. break;
  28. }
  29.  
  30. public class GalleryFragment extends Fragment {
  31.  
  32. @Override
  33. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  34. Bundle savedInstanceState) {
  35.  
  36. View rootView = inflater.inflate(R.layout.chapter, container, false);
  37.  
  38. Intent i = new Intent(getActivity(), GalleryActivity.class);
  39. startActivity(i);
  40.  
  41. return rootView;
  42. }
  43.  
  44. <?xml version="1.0" encoding="utf-8"?>
  45. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  46. android:layout_width="match_parent"
  47. android:layout_height="match_parent"
  48. android:orientation="vertical" >
  49.  
  50. </LinearLayout>
  51.  
  52. public class GalleryActivity extends Activity {
  53.  
  54. TextView textView1;
  55.  
  56. @Override
  57. protected void onCreate(Bundle savedInstanceState){
  58. super.onCreate(savedInstanceState);
  59. setContentView(R.layout.gallery_activity);
  60.  
  61. textView1=(TextView)findViewById(R.id.textView1);
  62.  
  63.  
  64. }
  65.  
  66. }
  67.  
  68. <?xml version="1.0" encoding="utf-8"?>
  69. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  70. android:layout_width="match_parent"
  71. android:layout_height="match_parent"
  72. android:orientation="vertical" >
  73.  
  74. <TextView
  75. android:id="@+id/textView1"
  76. android:layout_width="wrap_content"
  77. android:layout_height="wrap_content"
  78. android:text="Lesson Page" />
  79.  
  80. </LinearLayout>
  81.  
  82. Intent i = new Intent(context, GalleryActivity.class);
  83. startActivity(i);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement